Skip to content
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

to_netcdf can fail due to usage of CategoricalDtype #112

Open
smithara opened this issue Jul 2, 2024 · 1 comment
Open

to_netcdf can fail due to usage of CategoricalDtype #112

smithara opened this issue Jul 2, 2024 · 1 comment

Comments

@smithara
Copy link
Member

smithara commented Jul 2, 2024

Current versions of (pandas/xarray?) are now causing a failure in xarray.Dataset.to_netcdf with the datasets generated by viresclient where "Spacecraft" is stored as a pandas.Categorical, where this didn't happen before.

For example:

import pandas as pd
import xarray as xr

ds = xr.Dataset(
    data_vars={
        "x": ("t", pd.Categorical(["A", "B", "B", "A"], categories=["A", "B"]))
    }
)
ds.to_netcdf("test.h5")

fails with:

TypeError: Cannot interpret 'CategoricalDtype(categories=['A', 'B'], ordered=False, categories_dtype=object)' as a data type
@smithara
Copy link
Member Author

smithara commented Jul 2, 2024

Workaround:
Downgrade to xarray 2024.3.0

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

No branches or pull requests

1 participant