-
Say I have an xarray DataSet like this: Dimensions: (chain: 1, draw: 2000, coefficients_dim_0: 3)
Coordinates:
* chain (chain) int64 0
* draw (draw) int64 0 1 2 3 4 5 ... 1995 1996 1997 1998 1999
* coefficients_dim_0 (coefficients_dim_0) <U1 'a' 'b' 'c'
Data variables:
coefficients (chain, draw, coefficients_dim_0) float32 0.9644 ... ...
e (chain, draw) float32 1.665 1.665 1.665 ... 1.665 1.665
Attributes:
created_at: 2024-01-27T00:52:26.920296
arviz_version: 0.12.1
inference_library: pyro
inference_library_version: 1.8.4 I want to "explode" the names for Dimensions: (chain: 1, draw: 2000, coefficients_dim_0: 3)
Coordinates:
* chain (chain) int64 0
* draw (draw) int64 0 1 2 3 4 5 ... 1995 1996 1997 1998 1999
Data variables:
a (chain, draw) float32 1.665 1.665 1.665 ... 1.665 1.665
b (chain, draw) float32 1.665 1.665 1.665 ... 1.665 1.665
c (chain, draw) float32 1.665 1.665 1.665 ... 1.665 1.665
e (chain, draw) float32 1.665 1.665 1.665 ... 1.665 1.665
Attributes:
created_at: 2024-01-27T00:52:26.920296
arviz_version: 0.12.1
inference_library: pyro
inference_library_version: 1.8.4 |
Beta Was this translation helpful? Give feedback.
Answered by
dcherian
Jan 27, 2024
Replies: 2 comments 1 reply
-
Though of trying ValueError: cannot remove index coordinates with reset_coords: {'coefficients_dim_0'} |
Beta Was this translation helpful? Give feedback.
0 replies
-
How about https://docs.xarray.dev/en/stable/generated/xarray.DataArray.to_dataset.html xr.merge([ds["e"], ds["coefficients"].to_dataset(dim="coefficients_dim_0")]) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
paw-lu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about https://docs.xarray.dev/en/stable/generated/xarray.DataArray.to_dataset.html