home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 575080574

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
575080574 MDU6SXNzdWU1NzUwODA1NzQ= 3825 Accept lambda in methods with one obvious xarray argument 5635139 closed 0     3 2020-03-04T01:52:46Z 2020-03-20T17:14:20Z 2020-03-20T17:14:20Z MEMBER      

Branching from https://github.com/pydata/xarray/issues/3770

Here's the proposal: allow lambdas on methods where the primary argument is a single xarray object, and interpret lambas as though they'd be supplied in a pipe method followed by the current method. Taking the example from the linked issue:

```python

In [1]: import xarray as xr

In [2]: import numpy as np

In [3]: da = xr.DataArray(np.random.rand(2,3))

In [4]: da.where(da > 0.5)
Out[4]: <xarray.DataArray (dim_0: 2, dim_1: 3)> array([[ nan, 0.71442406, nan], [0.55748705, nan, nan]]) Dimensions without coordinates: dim_0, dim_1

this should be equivalent (currently not valid)

In [5]: da.where(lambda x: x > 0.5)

the longer version (currently works)

In [5]: da.pipe(lambda x: x.where(x > 0.5))

```

Others I miss from pandas: assign, and loc. I haven't gone through the list though assume there are others; we don't have to agree 100% on the list before starting with the most obvious ones, assuming we're in agreement with the principle.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3825/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

  • 0 rows from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.504ms · About: xarray-datasette