3
我有我與讀取的數據與此類似大熊貓平均每天,pandas.resample
Date,Temp1,Temp2
23-Oct-09 01:00:00,21.1,22.3
23-Oct-09 04:00:00,22.3,23.8
23-Oct-09 07:00:00,21.4,21.3
23-Oct-09 10:00:00,21.5,21.6
23-Oct-09 13:00:00,22.3,23.8
23-Oct-09 16:00:00,21.4,21.3
23-Oct-09 19:00:00,21.1,22.3
23-Oct-09 22:00:00,21.4,21.3
24-Oct-09 01:00:00,22.3,23.8
24-Oct-09 04:00:00,22.3,23.8
24-Oct-09 07:00:00,21.1,22.3
24-Oct-09 10:00:00,22.3,23.8
24-Oct-09 13:00:00,21.1,22.3
24-Oct-09 16:00:00,22.3,23.8
24-Oct-09 19:00:00,21.1,22.3
24-Oct-09 22:00:00,22.3,23.8
csv文件:
df=pd.read_csv('data.csv', index_col=0)
並轉換索引日期時間
df.index=pd.to_datetime(df.index)
現在我想要採取每個日常溫度的意思,我一直在嘗試使用pd.resample如下,但一直在接收錯誤。我讀過關於這裏的pandas.resample文檔和許多例子和我仍處於虧損狀態...
df_avg = df.resample('D', how = 'mean')
DataError: No numeric types to aggregate
我想df_avg是有日期時間指數和兩個2列的數據幀。我使用熊貓0.17.1和python 3.5.2,非常感謝任何幫助!
如果我的回答對您有所幫助,不要忘記[接受](http://meta.stackexchange.com/a/5235/295067)它。謝謝。 – jezrael
請注意,此方法已棄用,重新採樣代碼現在應爲df.resample('D')。mean() – PJW