home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 783272657

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
783272657 MDU6SXNzdWU3ODMyNzI2NTc= 4791 Assigning non-dimension coordinates does not conserve MultiIndex type 34008825 open 0     3 2021-01-11T11:03:00Z 2023-08-23T13:18:15Z   NONE      

What happened: Assigning a new non-dimension coordinate of type MultiIndex to a Dataset/DataArray returns an object that has the new coordinate as type Object instead of MultiIndex.

What you expected to happen: Adding a MultiIndex as a dimension coordinate to a Dataset keeps the type. It should be the same for non-dimension.

Minimal Complete Verifiable Example:

```python import numpy as np import pandas as pd import xarray as xr

ds = xr.Dataset( data_vars={'foo': (['x', 'y'], np.random.rand(2, 2))}, coords={'x': [1, 2], 'y': [1, 2]} ) idx = pd.MultiIndex.from_arrays([['a', 'b'], [5, 6]])

ds.assign_coords({'z': idx}) # Conserves MultiIndex type ds.assign_coords({'z': ('x', idx)}) # Does not conserve MultiIndex type ``` Anything else we need to know?:

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder: little LC_ALL: None LANG: en LOCALE: None.None libhdf5: 1.10.4 libnetcdf: 4.7.3 xarray: 0.16.1 pandas: 1.1.3 numpy: 1.19.1 scipy: 1.5.2 netCDF4: 1.5.3 pydap: installed h5netcdf: None h5py: None Nio: None zarr: 2.6.1 cftime: 1.3.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.30.0 distributed: 2.30.1 matplotlib: 3.3.3 cartopy: 0.18.0 seaborn: 0.11.0 numbagg: None pint: None setuptools: 50.3.0.post20201006 pip: 20.2.4 conda: 4.9.2 pytest: None IPython: 7.18.1 sphinx: 3.2.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4791/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

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