Open Hoeze opened 5 years ago
Thanks for the suggestion!
Generally we try to keep all of xarray's functions "metadata aware", rather overriding metadata. So the API feels a little out of place to me.
Maybe you could share a little bit more about your use case for this?
Thanks for your answer @shoyer. OK, then this can be closed, since this function should actually remove metadata for me :)
For example, lets consider a dataset with:
("obs", "features_1", "features_2", ..., "features_n")
x1 ("obs", "features_1"), x2 ("obs", "features_2"), ..., xn ("obs", "features_n")
Now I want to stick those side-by-side to get an array x_combined ("obs", "features")
with features = features_1 + ... + features_n"
.
@Hoeze is it possible to use xarray.stack
for your example? e.g.
features_i = ("features_1", "features_2", ..., "features_n")
x_combined = original.stack(features=features_i)
@TomNicholas No, not really. Stack can be only used to combine multiple coordinates into one coordinate, e.g. data[x, y, z] -> stacked_data[a, z]
with a
as a multi-index of x
and y
.
In this case, we do not have shared data with coordinates to combine.
Instead, multiple independent DataArrays should be concatenated along some dimension.
The most similar methods to this one are xr.concat
and xr.combine_nested
.
However, they do not allow to implicitly rename dimensions and force-delete non-shared metadata.
Hi, I wrote a helper function which allows to concatenate arrays like
xr.combine_nested
with the difference that it only supportsxr.DataArrays
, concatenates them by axis position similar tonp.concatenate
and overwrites all dimension names.I often need this to combine very different feature types.
Would it make sense to include this in xarray?