home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 567993968

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
567993968 MDU6SXNzdWU1Njc5OTM5Njg= 3782 Add groupby.pipe? 5635139 closed 0     4 2020-02-20T01:33:31Z 2020-02-21T14:37:44Z 2020-02-21T14:37:44Z MEMBER      

MCVE Code Sample

```python In [1]: import xarray as xr

In [3]: import numpy as np

In [4]: ds = xr.Dataset( ...: {"foo": (("x", "y"), np.random.rand(4, 3))}, ...: coords={"x": [10, 20, 30, 40], "letters": ("x", list("abba"))}, ...: )

In [5]: ds.groupby('letters')
Out[5]: DatasetGroupBy, grouped over 'letters' 2 groups with labels 'a', 'b'.

In [8]: ds.groupby('letters').sum(...) / ds.groupby('letters').count(...)
Out[8]: <xarray.Dataset> Dimensions: (letters: 2) Coordinates: * letters (letters) object 'a' 'b' Data variables: foo (letters) float64 0.4182 0.4995

In [9]: ds.groupby('letters').pipe(lambda x: x.sum() / x.count())

AttributeError Traceback (most recent call last) <ipython-input-9-c9b142ea051b> in <module> ----> 1 ds.groupby('letters').pipe(lambda x: x.sum() / x.count())

AttributeError: 'DatasetGroupBy' object has no attribute 'pipe'

```

Expected Output

I think we could add groupby.pipe, as a convenience?

Output of xr.show_versions()

In [12]: xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.6.8 (default, Aug 7 2019, 17:28:10) [...] python-bits: 64 OS: Linux OS-release: [...] machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.utf8 LOCALE: en_US.UTF-8 libhdf5: 1.10.4 libnetcdf: None xarray: 0.14.1 pandas: 0.25.3 numpy: 1.18.1 scipy: 1.4.1 netCDF4: None pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.1.2 cartopy: None seaborn: 0.10.0 numbagg: None setuptools: 45.0.0 pip: 20.0.2 conda: None pytest: 5.3.2 IPython: 7.11.1 sphinx: 2.3.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3782/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
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 237.387ms · About: xarray-datasette