home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 583065626

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/3674#issuecomment-583065626 https://api.github.com/repos/pydata/xarray/issues/3674 583065626 MDEyOklzc3VlQ29tbWVudDU4MzA2NTYyNg== 31126826 2020-02-06T19:17:49Z 2020-02-06T19:17:49Z CONTRIBUTOR

Actually, after updating to version 0.15 I've found another issue in the same context. More precisely, when using a multi-index with a non-categorical repeated coordinate and a categorical coordinate:

```python 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 Traceback (most recent call last): File "/home/matthieu/test.py", line 8, in <module> ds = df.set_index(['i1', 'i2']).to_xarray() File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 2867, in to_xarray return xarray.Dataset.from_dataframe(self) File "/opt/anaconda3/lib/python3.7/site-packages/xarray/core/dataset.py", line 4555, in from_dataframe idx = remove_unused_levels_categories(dataframe.index) File "/opt/anaconda3/lib/python3.7/site-packages/xarray/core/indexes.py", line 26, in remove_unused_levels_ categories index = pd.MultiIndex.from_arrays(levels, names=index.names) File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/multi.py", line 425, in from_arrays raise ValueError("all arrays must be same length") ValueError: all arrays must be same length `` but works fine wheni2` is not categorical.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  547091670
Powered by Datasette · Queries took 0.832ms · About: xarray-datasette