issues: 320007162
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
320007162 | MDU6SXNzdWUzMjAwMDcxNjI= | 2102 | resample DeprecationWarning only on 1-D arrays? | 17162724 | closed | 0 | 1 | 2018-05-03T17:13:55Z | 2018-05-08T17:36:22Z | 2018-05-08T17:36:22Z | CONTRIBUTOR | Code Sample, a copy-pastable example if possible```python da = xr.DataArray(np.array([1,2,3,4], dtype=np.float).reshape(2,2), ... coords=[pd.date_range('1/1/2000', '1/2/2000', freq='D'), ... np.linspace(0,1,num=2)], ... dims=['time', 'latitude']) da.resample(freq='M', dim='time', how='mean') /Users/Ray/anaconda/envs/rot-eof-dev-env/bin/ipython:1: DeprecationWarning:.resample() has been modified to defer calculations. Instead of passing 'dim' and 'how="mean", #instead consider using .resample(time="M").mean()#!/Users/Ray/anaconda/envs/rot-eof-dev-env/bin/pythonOut[66]:<xarray.DataArray (time: 1, latitude: 2)>array([[2., 3.]])Coordinates:* time (time) datetime64[ns] 2000-01-31* latitude (latitude) float64 0.0 1.0da.resample(time="M").mean() <xarray.DataArray (time: 1)>array([2.5])Coordinates:* time (time) datetime64[ns] 2000-01-31``` Problem descriptionThe DeprecationWarning example seems to only work for 1d arrays as it doesn't average along any dimension. A quick fix could be to show the warning only if the DataArray/Dataset is 1D. A more thorough fix could be to wrap Expected OutputSame as Output of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2102/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |