I have a DataSet ds_object that looks like this:
ds_object
<xarray.Dataset>
Dimensions: (time: 14392)
Coordinates:
* time (time) datetime64[ns] 2021-08-28T00:00:02.14...
Data variables:
variable .......
Where "variable" is:
<xarray.DataArray 'variable' ()>
array(0., dtype=float32)
Attributes:
units: count
I am trying to expand the zero-dimensional variable by time. So essentially, change 'variable' from a 0D to a 1D array, in the shape (1, 14392). variable would then have the same length as 'time', but with the singular value of variable repeated 14392 times.
I was able to do this:
variable = np.full((1,len(time)),variable)
Which gives variable the shape I need, but this goes back into ds_object as a coordinate variable for some reason:
ds_object = ds_object.assign(variable_new=(variable[0]))
print(ds_object)
<xarray.Dataset>
Dimensions: (time: 13164, variable_new: 13164)
Coordinates:
* time (time) datetime64[ns] 2021-08-28T00:00:02.14...
* variable_new (variable_new) float32 0.0 0.0 ... 0.0
Data variables: (12/28)
Why does this happen? How do I get variable_new added to ds_object as a new data variable?