📅  最后修改于: 2023-12-03 14:46:22.755000             🧑  作者: Mango
Pandas is a data manipulation library for Python. Pandas Period is used to represent a time span like a day, hour, minute, etc. Pandas Period.hour is used to represent a period of one hour.
p = pd.Period('2019-09-01 22:00', freq='H')
import pandas as pd
p = pd.Period('2019-09-01 22:00', freq='H')
print(p)
Output:
2019-09-01 22:00
import pandas as pd
p1 = pd.Period('2019-09-01 22:00', freq='H')
p2 = pd.Period('2019-09-01 23:00', freq='H')
diff = p2 - p1
print(diff)
Output:
1
Pandas Period.hour is a useful function for representing periods of one hour in Python. Pandas Period helps in dealing with time-series data and performing various operations on it.