天天看點

PeriodIndex月份轉換季度報錯,更改寫作方式報錯更正

PeriodIndex月份轉換季度報錯,更改寫作方式

報錯

B_month['Statistics_Q'] = pd.PeriodIndex(B_month.Statistics_date, freq='Q')

TypeError: Incorrect dtype

更正

B_month['Statistics_Q'] = pd.PeriodIndex(B_month["Statistics_date"].values, freq='Q')