pandas.PeriodIndex#

class pandas.PeriodIndex(data=None, ordinal=None, freq=None, dtype=None, copy=False, name=None, **fields)[源代码]#

不变的ndarray,保存指示时间规则周期的序数值。

索引键被装箱到携带元数据(例如,频率信息)的周期对象。

参数
data类数组(一维int np.ndarray或周期数组),可选

用于构建索引的可选的类似句点的数据。

copy布尔尔

复制一份输入ndarray。

freq字符串或期间对象,可选

Pandas周期串或相应的对象之一。

year整型、数组或系列,默认为无
month整型、数组或系列,默认为无
quarter整型、数组或系列,默认为无
day整型、数组或系列,默认为无
hour整型、数组或系列,默认为无
minute整型、数组或系列,默认为无
second整型、数组或系列,默认为无
dtype字符串或周期Dtype,默认为无

参见

Index

基本Pandas索引类型。

Period

表示一段时间。

DatetimeIndex

包含DateTime64数据的索引。

TimedeltaIndex

时间增量64数据的索引。

period_range

创建固定频率的周期索引。

示例

>>> idx = pd.PeriodIndex(year=[2000, 2002], quarter=[1, 3])
>>> idx
PeriodIndex(['2000Q1', '2002Q3'], dtype='period[Q-DEC]')

属性

day 

这段时间的天数。

dayofweek 

星期一=0,星期日=6的星期几。

day_of_week 

星期一=0,星期日=6的星期几。

dayofyear 

一年中的第几天。

day_of_year 

一年中的第几天。

days_in_month 

一个月中的天数。

daysinmonth 

一个月中的天数。

end_time 

获取时段结束的时间戳。

freq 

如果设置了频率对象,则返回该对象,否则为None。

freqstr 

如果设置了频率对象,则将其作为字符串返回,否则为None。

hour 

该时段的小时数。

is_leap_year 

指示日期是否属于闰年的逻辑指示。

minute 

该时间段的分钟数。

month 

月份为1月=1,12月=12。

quarter 

日期的第1季度。

second 

这一时期的第二个时期。

start_time 

获取时段开始的时间戳。

week 

一年中的第几周。

weekday 

星期一=0,星期日=6的星期几。

weekofyear 

一年中的第几周。

year 

该期间的年份。

qyear

方法:

asfreq \([freq, how] )

将周期数组转换为指定频率 freq

strftime \(*args, * *kwargs)

使用指定的Date_Format转换为索引。

to_timestamp \([freq, how] )

强制转换为Datetime数组/索引。