home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1115045538

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/3476#issuecomment-1115045538 https://api.github.com/repos/pydata/xarray/issues/3476 1115045538 IC_kwDOAMm_X85Cdj6i 3698640 2022-05-02T15:38:11Z 2022-08-08T15:32:52Z CONTRIBUTOR

This has been happening a lot to me lately when writing to zarr. Thanks to @bolliger32 for the tip - this usually works like a charm:

```python for v in list(ds.coords.keys()): if ds.coords[v].dtype == object: ds.coords[v] = ds.coords[v].astype("unicode")

for v in list(ds.variables.keys()): if ds[v].dtype == object: ds[v] = ds[v].astype("unicode") `` For whatever reason, clearing the encoding and/or using.astype(str)` doesn't seem to work as reliably. I don't have a good MRE for this but hope it helps others with the same issue.

note the flag raised by @FlorisCalkoen below - don't just throw this at all your writes! there are other object types (e.g. CFTime) which you probably don't want to convert to string. This is just a patch to get around this issue for dataarrays with string coords/variables.

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