Pandas Panel resampling alternatives

折月煮酒 提交于 2019-12-12 03:17:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!