pandas.PeriodIndex.end_time #

属性 周期索引。结束时间[来源] #

获取该期间结束的时间戳。

返回
时间戳

也可以看看

Period.start_time

返回开始时间戳。

Period.dayofyear

返回一年中的日期。

Period.daysinmonth

返回该月的天数。

Period.dayofweek

返回星期几。

例子

对于期间:

>>> pd.Period('2020-01', 'D').end_time
Timestamp('2020-01-01 23:59:59.999999999')

对于系列:

>>> period_index = pd.period_range('2020-1-1 00:00', '2020-3-1 00:00', freq='M')
>>> s = pd.Series(period_index)
>>> s
0   2020-01
1   2020-02
2   2020-03
dtype: period[M]
>>> s.dt.end_time
0   2020-01-31 23:59:59.999999999
1   2020-02-29 23:59:59.999999999
2   2020-03-31 23:59:59.999999999
dtype: datetime64[ns]

对于周期索引:

>>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M")
>>> idx.end_time
DatetimeIndex(['2023-01-31 23:59:59.999999999',
               '2023-02-28 23:59:59.999999999',
               '2023-03-31 23:59:59.999999999'],
               dtype='datetime64[ns]', freq=None)