1
所以我有一個形式的數據框:index是一個日期,然後我有一個由np.arrays組成的形狀爲180x360的列。我想要做的是計算數據集的每週平均值。數據幀的例子:熊貓resample numpy數組
vika geop
1990-01-01 06:00:00 [[50995.954225, 50995.954225, 50995.954225, 50...
1990-01-02 06:00:00 [[51083.0576138, 51083.0576138, 51083.0576138,...
1990-01-03 06:00:00 [[51045.6321168, 51045.6321168, 51045.6321168,...
1990-01-04 06:00:00 [[50499.8436192, 50499.8436192, 50499.8436192,...
1990-01-05 06:00:00 [[49823.5114237, 49823.5114237, 49823.5114237,...
1990-01-06 06:00:00 [[50050.5148846, 50050.5148846, 50050.5148846,...
1990-01-07 06:00:00 [[50954.5188533, 50954.5188533, 50954.5188533,...
1990-01-08 06:00:00 [[50995.954225, 50995.954225, 50995.954225, 50...
1990-01-09 06:00:00 [[50628.1596088, 50628.1596088, 50628.1596088,...
我已經試過到目前爲止是簡單
df = df.resample('W-MON')
但我得到這個錯誤:
pandas.core.groupby.DataError: No numeric types to aggregate
我試圖改變數據類型要列出的列,但它仍然不起作用。任何想法如何用resample或其他方法做到這一點?
存儲陣列numpy的內部數據幀是不是一個好主意一般。你可以做的事情會很有限(正如你發現的那樣)。您的數據可能非常適合建立在numpy和pandas之上的xarray.Dataset:http://xarray.pydata.org/en/stable/data-structures.html,[resample](http:// xarray.pydata.org/en/stable/time-series.html#resampling-and-grouped-operations) – TomAugspurger