issues: 706568536
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
706568536 | MDU6SXNzdWU3MDY1Njg1MzY= | 4450 | GroupBy.map with keep_attrs=True gives error | 31803994 | open | 0 | 3 | 2020-09-22T17:34:37Z | 2022-06-27T17:23:10Z | NONE | I wanted to apply a function (not as simple as
Error``` --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-26-e572326fea03> in <module> 2 import xarray as xr 3 ds = xr.tutorial.open_dataset("air_temperature") ----> 4 test_map = ds.groupby('lat').map(np.mean, keep_attrs=True) 5 test_map.lat /opt/conda/lib/python3.8/site-packages/xarray/core/groupby.py in map(self, func, args, shortcut, **kwargs) 921 # ignore shortcut if set (for now) 922 applied = (func(ds, *args, **kwargs) for ds in self._iter_grouped()) --> 923 return self._combine(applied) 924 925 def apply(self, func, args=(), shortcut=None, **kwargs): /opt/conda/lib/python3.8/site-packages/xarray/core/groupby.py in _combine(self, applied) 941 def _combine(self, applied): 942 """Recombine the applied objects like the original.""" --> 943 applied_example, applied = peek_at(applied) 944 coord, dim, positions = self._infer_concat_args(applied_example) 945 combined = concat(applied, dim) /opt/conda/lib/python3.8/site-packages/xarray/core/utils.py in peek_at(iterable) 181 """ 182 gen = iter(iterable) --> 183 peek = next(gen) 184 return peek, itertools.chain([peek], gen) 185 /opt/conda/lib/python3.8/site-packages/xarray/core/groupby.py in <genexpr>(.0) 920 """ 921 # ignore shortcut if set (for now) --> 922 applied = (func(ds, *args, **kwargs) for ds in self._iter_grouped()) 923 return self._combine(applied) 924 <__array_function__ internals> in mean(*args, **kwargs) TypeError: _mean_dispatcher() got an unexpected keyword argument 'keep_attrs' ```Output of <tt>xr.show_versions()</tt>``` INSTALLED VERSIONS ------------------ commit: None python: 3.8.5 | packaged by conda-forge | (default, Aug 21 2020, 18:21:27) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 4.19.112+ machine: x86_64 processor: x86_64 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.16.0 pandas: 1.1.1 numpy: 1.19.1 scipy: 1.5.2 netCDF4: 1.5.4 pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: 2.4.0 cftime: 1.2.1 nc_time_axis: 1.2.0 PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2.20.0 distributed: 2.24.0 matplotlib: 3.2.2 cartopy: 0.18.0 seaborn: 0.10.1 numbagg: None pint: None setuptools: 49.6.0.post20200814 pip: 20.2.2 conda: 4.8.3 pytest: None IPython: 7.17.0 sphinx: None ``` |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/4450/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |