home / github / issues

Menu
  • GraphQL API
  • Search all tables

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 description

1)

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 Output

Output of xr.show_versions()

In [23]: xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.6.5.final.0 python-bits: 64 OS: Linux OS-release: 4.16.11-100.fc26.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_AU.UTF-8 LOCALE: en_AU.UTF-8 xarray: 0.10.6 pandas: 0.23.4 numpy: 1.14.4 scipy: 1.1.0 netCDF4: 1.4.0 h5netcdf: None h5py: None Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: 0.17.5 distributed: 1.21.8 matplotlib: 2.2.2 cartopy: None seaborn: None setuptools: 39.2.0 pip: 10.0.1 conda: None pytest: 3.6.0 IPython: 6.4.0 sphinx: None
{
    "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

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.67ms · About: xarray-datasette