Python | Pandas PeriodIndex.hour

Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas PeriodIndex.hour attribute return the hour of the period for the given PeriodIndex object.
Syntax : PeriodIndex.hour Parameters : None Return : Index object containing hour values.
Example #1: Use PeriodIndex.hour attribute to find the hour value of the period for the given PeriodIndex object.
Python3
# importing pandas as pdimport pandas as pd# Create the PeriodIndex objectpidx = pd.PeriodIndex(start ='2005-12-21 08:45 ', end ='2005-12-21 11:55', freq ='H')# Print the PeriodIndex objectprint(pidx) |
Output : 
Python3
# return the hour valuepidx.hour |
Output : 
Python3
# importing pandas as pdimport pandas as pd# Create the PeriodIndex objectpidx = pd.PeriodIndex(start ='2011-02-1', end ='2011-02-14', freq ='D')# Print the PeriodIndex objectprint(pidx) |
Output : 
Python3
# return the hour valuepidx.hour |
Output : 



