79412787

Date: 2025-02-04 19:17:46
Score: 0.5
Natty:
Report link

How to change the order of dimension of a xarray: transpose

In your example, that would be:

rainfall_dataset['rainfall_depth'].T.transpose('time','x','y')

i.e.:

Dataset['Variable'].T.transpose('dim1','dim2','dim3)

Required: List all dimensions in the desired order.

If you want a modification of your variable in your dataset:

rainfall_dataset['rainfall_depth'] = rainfall_dataset['rainfall_depth'].T.transpose('time','x','y')

i.e.:

Dataset['Variable'] = Dataset['Variable'].T.transpose('dim1','dim2','dim3)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): How to
  • Low reputation (1):
Posted by: Anne-Sophie