IncompatibleFrequency: Frequency <MonthEnd> cannot be resampled to <3 * MonthEnds>, as they are not sub or super periods
# 重采样之前,请尝试从更改PeriodIndex为DateTimeIndex:
ts.index = ts.index.astype('datetime64[ns]')
print(ts.resample('3M', kind='period').sum())
2019-01 3
2019-04 12
2019-07 21
2019-10 30
2020-01 39
2020-04 48
2020-07 57
2020-10 66
2021-01 24
Freq: 3M, dtype: int64
参考链接:https://www.pythonheidong.com/blog/article/367323/86972cfe6819c2d35fd9/