-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Multi-index with categorical values #3674
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
Comments
Thanks for reporting again. Please add comments here if you find another not-working case. |
xref: #3670 |
Thank you for your work on this! I haven't found any other issue at the moment, I guess we can close this issue. |
Actually, after updating to version 0.15 I've found another issue in the same context. import pandas as pd
i1 = pd.Series([0, 0])
cat = pd.CategoricalDtype(categories=['foo', 'bar', 'baz'])
i2 = pd.Series(['foo', 'bar'], dtype=cat)
df = pd.DataFrame({'i1': i1, 'i2': i2, 'values': [1, 2]})
ds = df.set_index(['i1', 'i2']).to_xarray()
print(ds) raises the following error
but works fine when |
@fujiisoup Since you implemented |
@mancellin |
Yes, I'll give it a try. |
* Fix bug for multi-index with categorical values. See issue #3674. * Blacked. * Add line in whats-new.rst. * Remove forgotten print. Co-authored-by: Matthieu Ancellin <[email protected]>
Building a dataset from pandas with a multi-index with categorical values:
Expected output:
Actual output:
It is not wrong, but it is inconsistent with the non-categorical case (which gives the expected output above) and the single-index case (no filling with NaNs for single index).
Output of
xr.show_versions()
xarray: 0.14.1
pandas: 0.25.3
numpy: 1.17.4
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
setuptools: 44.0.0.post20200106
pip: 19.3.1
conda: None
pytest: None
IPython: None
sphinx: None
The text was updated successfully, but these errors were encountered: