You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes GH276
Exmaple usage:
In [8]: ds = xray.Dataset({'x': range(3), 'y': ('x', list('abc'))})
In [9]: ds
Out[9]:
<xray.Dataset>
Dimensions: (x: 3)
Coordinates:
* x (x) int64 0 1 2
Data variables:
y (x) |S1 'a' 'b' 'c'
In [10]: ds.swap_dims({'x': 'y'})
Out[10]:
<xray.Dataset>
Dimensions: (y: 3)
Coordinates:
* y (y) |S1 'a' 'b' 'c'
x (y) int64 0 1 2
Data variables:
*empty*
This is a slightly more verbose API than strictly necessary, because the new
dimension names must be along existing dimensions (e.g., we could spell this
`ds.set_dims(['y'])`). But I still think it's a good idea, for two reasons:
1. It's more explicit. Users control know which dimensions are being swapped.
2. It opens up the possibility of specifying new dimensions with dictionary
like syntax, e.g., `ds.swap_dims('x': ('y', list('abc')))`
CC aykuznetsova
0 commit comments