-
Hi there! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
unfortunately the canonical method ( In [8]: ds = xr.Dataset({"a": ("x", [1.3, 6.2])}, coords={"x": [0, 1]})
...: ds
Out[8]:
<xarray.Dataset>
Dimensions: (x: 2)
Coordinates:
* x (x) int64 0 1
Data variables:
a (x) float64 1.3 6.2
In [9]: ds.assign(x=lambda ds: ds.x.astype(float))
Out[9]:
<xarray.Dataset>
Dimensions: (x: 2)
Coordinates:
* x (x) float64 0.0 1.0
Data variables:
a (x) float64 1.3 6.2 I think extending |
Beta Was this translation helpful? Give feedback.
unfortunately the canonical method (
astype
) indeed does not allow converting the coords. For data variables it would have been possible to specify a dict that maps names to dtypes (this is missing from theDataset.astype
documentation). To work around that, we can useassign
:I think e…