报错信息
IncompatibleFrequency: Frequency <MonthEnd>
cannot be resampled to <3 * MonthEnds>, as they are not sub or super periods
源代码
prng = pd.period_range('2016','2017',freq = 'M')
ts = pd.Series(np.arange(len(prng)), index = prng)
print(ts)
print(ts.resample('3M').sum()) # 降采样
修改后的代码
rng = pd.period_range('2016','2017',freq = 'M')
ts = pd.Series(np.arange(len(prng)), index = prng)
print(ts)
# 修改部分
td.index = td.index.astype('datetime64[ns]')
print(td.resample('3M', kind='period').sum()) # 降采样
网友评论