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

Dataset character coordinates change to object upon use in Dataset #2658

Closed
equaeghe opened this issue Jan 7, 2019 · 2 comments · Fixed by #4759
Closed

Dataset character coordinates change to object upon use in Dataset #2658

equaeghe opened this issue Jan 7, 2019 · 2 comments · Fixed by #4759
Labels

Comments

@equaeghe
Copy link

equaeghe commented Jan 7, 2019

Code Sample

>>> import xarray as xr

>>> test = xr.Dataset(coords={'xy': ['x', 'y']})

>>> test
<xarray.Dataset>
Dimensions:  (xy: 2)
Coordinates:
  * xy       (xy) <U1 'x' 'y'  # NOTE '<U1' dtype
Data variables:
    *empty*

>>> test['test'] = xr.DataArray(np.array([0, 0]), dims=['xy'])

>>> test
<xarray.Dataset>
Dimensions:  (xy: 2)
Coordinates:
  * xy       (xy) object 'x' 'y'  # NOTE 'object' dtype
Data variables:
    test     (xy) int64 0 0

Problem description

The coordinate dtype changes from <U1 to object.

Expected Output

The coordinate dtype should not change.

Output of xr.show_versions()

/usr/lib64/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`. from ._conv import register_converters as _register_converters

INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Linux
OS-release: 4.14.83-gentoo
machine: x86_64
processor: Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz
byteorder: little
LC_ALL: None
LANG: nl_BE.UTF-8
LOCALE: nl_BE.UTF-8

xarray: 0.10.8
pandas: 0.19.1
numpy: 1.14.5
scipy: 0.19.1
netCDF4: 1.3.1
h5netcdf: None
h5py: 2.7.1
Nio: None
zarr: None
bottleneck: 1.2.1
cyordereddict: None
dask: None
distributed: None
matplotlib: 2.2.2
cartopy: None
seaborn: None
setuptools: 36.7.2
pip: 9.0.1
conda: None
pytest: 3.2.2
IPython: 5.4.1
sphinx: 1.7.5

@shoyer shoyer added the bug label Jan 7, 2019
@shoyer
Copy link
Member

shoyer commented Jan 7, 2019

Hmm, this is a little puzzling. I'll mark this as a bug.

@mathause
Copy link
Collaborator

mathause commented Nov 9, 2020

Could be the same reason as #4543: pd.Index(["a", "b"]) has dtype=object

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

Successfully merging a pull request may close this issue.

3 participants