issues: 400039356
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
400039356 | MDU6SXNzdWU0MDAwMzkzNTY= | 2685 | porting to new resample when how is lambda/function unclear, wrong advice given. | 410907 | closed | 0 | 1 | 2019-01-16T23:11:35Z | 2023-09-12T15:54:41Z | 2023-09-12T15:54:41Z | NONE | Code Sample, a copy-pastable example if possible```python In [19]: da = xr.DataArray(np.linspace(0, 11, num=12), ...: ... coords=[pd.date_range('15/12/1999', ...: ... periods=12, freq=pd.DateOffset(months=1))], ...: ... dims='time') ...: ...: In [20]: fn = lambda values, axis: 3 In [21]: da.resample('QS-DEC', 'time', how=fn) /home/lexfed/miniconda3/envs/jive/bin/ipython:1: FutureWarning: .resample() has been modified to defer calculations. Instead of passing 'dim' and how="<function \<lambda> at 0x7f1f9e573510>", instead consider using .resample(time="QS-DEC").<function \<lambda> at 0x7f1f9e573510>('time') #!/home/lexfed/miniconda3/envs/jive/bin/python Out[21]: <xarray.DataArray (time: 4)> array([3, 3, 3, 3]) Coordinates: * time (time) datetime64[ns] 1999-12-01 2000-03-01 2000-06-01 2000-09-01 ``` Problem description1) Moving to new resample interface in newer xarray releases, it isn't clear how to port code where the how key word argument is a function/lambda. Can someone please advise how to port code utilising passing to the how argument a function/lambda/etc. 2) The Future Warning given, doesn't actually make sense where how is a function or lambda, that is not an attribute of the result of a resample. e.g. ``` instead consider using .resample(time="QS-DEC").<function \<lambda> at 0x7f1f9e573510>('time') ``` Expected OutputOutput of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2685/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |