Generally this isn't a problem, since the coords are carried over by the resulting DataArrays:
In [11]:
ds=xray.Dataset({
'a':pd.DataFrame(pd.np.random.rand(10,3)),
'b':pd.Series(pd.np.random.rand(10))
})
ds.coords['c'] =pd.Series(pd.np.random.rand(10))
dsOut[11]:
<xray.Dataset>Dimensions: (dim_0: 10, dim_1: 3)
Coordinates:
*dim_0 (dim_0) int640123456789*dim_1 (dim_1) int64012c (dim_0) float640.93180.28990.38530.62350.94360.7928 ...
Datavariables:
a (dim_0, dim_1) float640.57070.94850.35410.59870.4060.7992 ...
b (dim_0) float640.41060.23160.58040.63930.57150.6463 ...
In [12]:
ds.apply(lambdax: x*2)
Out[12]:
<xray.Dataset>Dimensions: (dim_0: 10, dim_1: 3)
Coordinates:
c (dim_0) float640.93180.28990.38530.62350.94360.7928 ...
*dim_0 (dim_0) int640123456789*dim_1 (dim_1) int64012Datavariables:
a (dim_0, dim_1) float641.1411.8970.70811.1970.8121.598 ...
b (dim_0) float640.82120.46311.1611.2791.1431.2930.3507 ...But if there's an operation that removes the coords from the DataArrays, the coords are not there on the result (notice c below).
Should the Dataset retain them? Either always or with a keep_coords argument, similar to keep_attrs.
In [13]:
ds=xray.Dataset({
'a':pd.DataFrame(pd.np.random.rand(10,3)),
'b':pd.Series(pd.np.random.rand(10))
})
ds.coords['c'] =pd.Series(pd.np.random.rand(10))
dsOut[13]:
<xray.Dataset>Dimensions: (dim_0: 10, dim_1: 3)
Coordinates:
*dim_0 (dim_0) int640123456789*dim_1 (dim_1) int64012c (dim_0) float640.41210.25070.63260.40310.61690.4410.1146 ...
Datavariables:
a (dim_0, dim_1) float640.48130.24790.51580.27870.06672 ...
b (dim_0) float640.26380.57880.65910.71740.36450.5655 ...
In [14]:
ds.apply(lambdax: x.to_pandas()*2)
Out[14]:
<xray.Dataset>Dimensions: (dim_0: 10, dim_1: 3)
Coordinates:
*dim_0 (dim_0) int640123456789*dim_1 (dim_1) int64012Datavariables:
a (dim_0, dim_1) float640.96270.49571.0320.55740.13340.8289 ...
b (dim_0) float640.52751.1581.3181.4350.72911.1310.1903 ...
Generally this isn't a problem, since the coords are carried over by the resulting
DataArrays:But if there's an operation that removes the coords from the
DataArrays, the coords are not there on the result (noticecbelow).Should the
Datasetretain them? Either always or with akeep_coordsargument, similar tokeep_attrs.