问题
I often use pd.Series.resample(), and am wondering if there is a way to resample/ interpolate monthly gridded data in the form (time,lat, lon) to say 'MS' (monthly start). I understand the feature is not directly implemented in Panel. Is there a workaround?
回答1:
You should check out the xray package. It is an N-dimensional labeled array package that extends much of the pandas resampling/group-by functionality. It is a pure python package so is easy to install and includes some really nice utilities for netCDF I/O.
For example, you could resample a xray DataArray object da
to a month start frequency like this:
da_ms = da.resample('MS', dim='time', how='mean')
Full disclosure, I am one of the xray developers, but this is exactly why xray has been developed.
来源:https://stackoverflow.com/questions/33130490/pandas-panel-resampling-alternatives