Skip to content

selection from MultiIndex does not work properly #3512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fujiisoup opened this issue Nov 12, 2019 · 0 comments · Fixed by #3520
Closed

selection from MultiIndex does not work properly #3512

fujiisoup opened this issue Nov 12, 2019 · 0 comments · Fixed by #3520

Comments

@fujiisoup
Copy link
Member

MCVE Code Sample

da = xr.DataArray([0, 1], dims=['x'], coords={'x': [0, 1], 'y': 'a'})
db = xr.DataArray([2, 3], dims=['x'], coords={'x': [0, 1], 'y': 'b'})
data = xr.concat([da, db], dim='x').set_index(xy=['x', 'y'])
data.sel(y='a')

>>> <xarray.DataArray (x: 4)>
>>> array([0, 1, 2, 3])
>>> Coordinates:
>>>   * x        (x) int64 0 1

Expected Output

>>> <xarray.DataArray (x: 2)>
>>> array([0, 1])
>>> Coordinates:
>>>   * x        (x) int64 0 1

Problem Description

Should select the array

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-957.10.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1

xarray: 0.14.0
pandas: 0.24.2
numpy: 1.15.4
scipy: 1.2.1
netCDF4: 1.4.2
pydap: None
h5netcdf: None
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: None
distributed: None
matplotlib: 3.0.2
cartopy: None
seaborn: 0.9.0
numbagg: None
setuptools: 40.8.0
pip: 19.0.3
conda: None
pytest: 5.0.0
IPython: 7.3.0
sphinx: None

Sorry for being quiet for a long time. I hope I could send a fix for this in a few days...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant