(我认为)我有代表datetime
间隔重采样大熊猫列DATETIME
列列的数据集,日期时间转化用:
for col in df.columns:
df.rename({col: pd.to_datetime(col, infer_datetime_format=True)}, inplace=True)
然后,我需要resample
列(一年一个月2001-01“)到宿舍使用mean
我试图
df = df.resample('1q', how='mean', axis=1)
的DataFrame
也有multindex设置['RegionName', 'County']
但我得到的错误:
Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'
是在to_datetime
功能或在错误的取样问题?
你可以发布您的数据框的头几行?根据您提供的信息,'df.rename'语句应该失败。 –