Reshaping and reorganizing data¶
These methods allow you to reorganize
Reordering dimensions¶
To reorder dimensions on a DataArray
or across all variables
on a Dataset
, use transpose()
or the
.T
property:
In [1]: ds = xr.Dataset({'foo': (('x', 'y', 'z'), [[[42]]]), 'bar': (('y', 'z'), [[24]])})
In [2]: ds.transpose('y', 'z', 'x')
Out[2]:
<xarray.Dataset>
Dimensions: (x: 1, y: 1, z: 1)
Dimensions without coordinates: x, y, z
Data variables:
foo (y, z, x) int64 42
bar (y, z) int64 24
In [3]: ds.T