我想将对象从pandas.core.indexes.accessors.PeriodProperties转换为Datetime变量。
例如,我想将格式为"2019Q1“的句号变量(不是字符串)转换为日期时间格式"2019-03-31”。
发布于 2021-02-21 18:08:39
假设您有像pi这样的代码,如
pi = pd.PeriodIndex(["2019Q1", "2019Q2"], freq='Q')然后你想要
pi.to_timestamp() + pd.offsets.QuarterEnd(0)
Out[11]: DatetimeIndex(['2019-03-31', '2019-06-30'], dtype='datetime64[ns]', freq=None)它基本上被描述为here。
https://stackoverflow.com/questions/66298238
复制相似问题