pandas.Period

pandas.Period(value=None, freq=None, ordinal=None, year=None, month=None, quarter=None, day=None, hour=None, minute=None, second=None)
表示一段时间。

Parameters

value 代表的时间段
freq 时期字符串
ordinal
year 时期对应的年
month 时期对应的月
quarter 时期的季度值
day 时期对应的天
hour 时期对应的小时
minute 时期对应的分钟
second 时期对应的秒

Attributes

属性 应用 输出
day pd.Period("2021-10-01").day 1
dayofweek pd.Period("2021-10-01").dayofweek 4
dayofyear pd.Period("2021-10-01").dayofyear 274
days_in_month pd.Period("2021-10-01").days_in_month 31
daysinmonth pd.Period("2021-10-01").daysinmonth 31
hour pd.Period("08:08:08").hour 8
minute pd.Period("08:08:08").minute 8
qyear pd.Period("08:08:08").qyear 1
second pd.Period("08:08:08").second 8
start_time pd.Period("2021-10-01").start_time Timestamp(‘2021-10-01 00:00:00’)
week pd.Period("2021-10-01").week 39
weekday pd.Period("2021-10-01").weekday 4
end_time pd.Period("2021-10-01").end_time Timestamp(‘2021-10-01 23:59:59.999999999’)
freq pd.Period("2021-10-01").freq
freqstr pd.Period("2021-10-01").freqstr ‘D’
is_leap_year pd.Period("2021-10-01").is_leap_year False
month pd.Period("2021-10-01").month 10
ordinal pd.Period("2021-10-01").ordinal 18901
quarter pd.Period("2021-10-01").quarter 4
weekofyear pd.Period("2021-10-01").weekofyear 39
year pd.Period("2021-10-01").year 2021

Methods

asfreq 在间隔的开始或结束处将周期转换为所需的频率
strftime 根据选定的fmt,返回Period的字符串表现形式
to_timestamp 返回时期的时间戳表示