How to format numbers in xarray? #5865
-
I want to do
|
Beta Was this translation helpful? Give feedback.
Answered by
andersy005
Nov 12, 2021
Replies: 2 comments 3 replies
-
Is there a way to do it in numpy? |
Beta Was this translation helpful? Give feedback.
0 replies
-
@ahuang11, would this work for you? In [9]: import xarray as xr
In [10]: da = xr.DataArray([5., 6., 7.])
In [11]: xr.DataArray([f"{s:.2f}" for s in da.data])
Out[11]:
<xarray.DataArray (dim_0: 3)>
array(['5.00', '6.00', '7.00'], dtype='<U4')
Dimensions without coordinates: dim_0 |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
ahuang11
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ahuang11, would this work for you?