pandas.PeriodIndex.to_timestamp#
- PeriodIndex.to_timestamp(freq=None, how='start')[源代码]#
转换为 DatetimeArray/Index。
- Parameters:
- freqstr 或 DateOffset,可选
目标频率。默认值为 ‘D’(用于周或更长),否则为 ‘s’。
- how{‘s’, ‘e’, ‘start’, ‘end’}
是否使用被转换时间段的开始或结束。
- Returns:
- DatetimeArray/Index
Examples
>>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M") >>> idx.to_timestamp() DatetimeIndex(['2023-01-01', '2023-02-01', '2023-03-01'], dtype='datetime64[ns]', freq='MS')