home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 816016031

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
816016031 MDU6SXNzdWU4MTYwMTYwMzE= 4955 set_index does not respect keep_attrs 31640292 closed 0     2 2021-02-25T02:22:05Z 2022-03-17T17:11:41Z 2022-03-17T17:11:41Z CONTRIBUTOR      

What happened: set_index removes attributes from a coordinate, even with xr.set_options(keep_attrs=True)

What you expected to happen: The attributes to be preserved through the coordinate renaming

Minimal Complete Verifiable Example:

python import xarray as xr xr.set_options(keep_attrs=True) x = xr.DataArray([1,2], dims=['x']) x.coords['x'] = (['x'],[2,3], {"name":"coord_1"}) x.coords['a'] = (['x'],[0,1], {"name":"coord 2"}) x.set_index(x='a').x.attrs # should be {"name":"coord 2"}, is {}

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.8.5 | packaged by conda-forge | (default, Sep 24 2020, 16:55:52) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 3.10.0-1160.11.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en.UTF-8 LOCALE: None.None libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.16.2 pandas: 1.2.0 numpy: 1.19.1 scipy: 1.6.0 netCDF4: 1.5.5.1 pydap: None h5netcdf: 0.8.1 h5py: 3.1.0 Nio: None zarr: None cftime: 1.3.1 nc_time_axis: 1.2.0 PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2021.01.0 distributed: 2021.01.0 matplotlib: 3.3.3 cartopy: 0.18.0 seaborn: 0.11.1 numbagg: None pint: 0.16.1 setuptools: 49.6.0.post20210108 pip: 20.2.3 conda: None pytest: None IPython: 7.18.1 sphinx: 3.4.3
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4955/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
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 0.728ms · About: xarray-datasette