issues: 826990294
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
826990294 | MDU6SXNzdWU4MjY5OTAyOTQ= | 5018 | Missing name in index of series created from DataArray.to_series() after reindex | 1593312 | closed | 0 | 3 | 2021-03-10T02:50:57Z | 2023-02-18T14:23:31Z | 2023-02-18T14:23:31Z | NONE | What happened: If a What you expected to happen: I expect the Minimal Complete Verifiable Example: ```python import numpy as np import pytest import xarray as xr def test_multiindex(): array = xr.DataArray( np.arange(12).reshape((4, 3)), coords=[ ("foo", ["a", "b", "c", "d"]), ("bar", ["x", "y", "z"]), ] ) assert array.to_series().index.names == ["foo", "bar"] def test_multiindex_reindex(): array = xr.DataArray( np.arange(12).reshape((4, 3)), coords=[ ("foo", ["a", "b", "c", "d"]), ("bar", ["x", "y", "z"]), ] ) series = array.reindex(bar=["x", "y"]).to_series() assert series.index.names == ["foo", "bar"] def test_index_str(): array = xr.DataArray(np.arange(4), coords=[("foo", ["a", "b", "c", "d"])]) assert array.to_series().index.names == ["foo"] def test_index_str_reindex(): array = xr.DataArray(np.arange(4), coords=[("foo", ["a", "b", "c", "d"])]) series = array.reindex(foo=["a", "b", "c"]).to_series() assert series.index.names == ["foo"] def test_index_int(): array = xr.DataArray(np.arange(4), coords=[("foo", [1, 2, 3, 4])]) assert array.to_series().index.names == ["foo"] def test_index_int_reindex(): array = xr.DataArray(np.arange(4), coords=[("foo", [1, 2, 3, 4])]) series = array.reindex(foo=[1, 2, 3]).to_series() assert series.index.names == ["foo"] ``` Version 0.16.2: It works as expected for ``` ================================================= test session starts ================================================= platform win32 -- Python 3.8.6, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 plugins: cov-2.11.1 collected 6 items tests\test_to_series_index.py ...F.F [100%] ====================================================== FAILURES ======================================================= _______ test_index_str_reindex __________
tests\test_to_series_index.py:39: AssertionError _______ test_index_int_reindex __________
tests\test_to_series_index.py:50: AssertionError =============================================== short test summary info =============================================== FAILED tests/test_to_series_index.py::test_index_str_reindex - AssertionError: assert FrozenList([None]) == ['foo'] FAILED tests/test_to_series_index.py::test_index_int_reindex - AssertionError: assert FrozenList([None]) == ['foo'] ============================================= 2 failed, 4 passed in 0.61s ============================================= ``` Version 0.17.0: Index name is missing after reindex on both single level ``` ================================================= test session starts ================================================= platform win32 -- Python 3.8.6, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 plugins: cov-2.11.1 collected 6 items tests\test_to_series_index.py .F.F.F [100%] ====================================================== FAILURES ======================================================= _______ test_multiindex_reindex _________
tests\test_to_series_index.py:28: AssertionError _______ test_index_str_reindex __________
tests\test_to_series_index.py:39: AssertionError _______ test_index_int_reindex __________
tests\test_to_series_index.py:50: AssertionError =============================================== short test summary info =============================================== FAILED tests/test_to_series_index.py::test_multiindex_reindex - AssertionError: assert FrozenList(['foo', None]) == [... FAILED tests/test_to_series_index.py::test_index_str_reindex - AssertionError: assert FrozenList([None]) == ['foo'] FAILED tests/test_to_series_index.py::test_index_int_reindex - AssertionError: assert FrozenList([None]) == ['foo'] ============================================= 3 failed, 3 passed in 0.61s ============================================= ``` Environment: Output of <tt>xr.show_versions()</tt> for 0.16.2commit: None python: 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 158 Stepping 13, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: English_United States.1252 libhdf5: None libnetcdf: None xarray: 0.16.2 pandas: 1.2.3 numpy: 1.20.1 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None 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: None cartopy: None seaborn: None numbagg: None pint: None setuptools: 53.0.0 pip: 21.0.1 conda: None pytest: 6.2.2 IPython: 7.21.0 sphinx: NoneOutput of <tt>xr.show_versions()</tt> for 0.17.0commit: None python: 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 158 Stepping 13, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: English_United States.1252 libhdf5: None libnetcdf: None xarray: 0.17.0 pandas: 1.2.3 numpy: 1.20.1 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None 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: None cartopy: None seaborn: None numbagg: None pint: None setuptools: 53.0.0 pip: 21.0.1 conda: None pytest: 6.2.2 IPython: 7.21.0 sphinx: None |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/5018/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |