-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to make DataArray.transpose also transpose coords #1856
Comments
To be honest, I'm not sure skipping coordinates was actually intentional. In most cases, I suspect transposing coordinates simply doesn't matter because either (1) there are no multi-dimensional coordinates or (2) xarray usually doesn't care much about dimension order (so it doesn't matter). I would support adding a Anyone else have opinions on this API? |
Also hitting this issue. (Use case: formatting netcdf files for some R code that does not have labeled indexing... ugh). Thanks @phausamann for the work around. Default transposing of coods makes sense to me. |
Honestly, we could probably consider the DataArray behavior to be a bug. In general DataArray methods should work exactly like Dataset methods on a Dataset with a single data variable. (In fact, this is how we implement many DataArray methods.) |
* Add transpose_coords option to DataArray.transpose Fixes #1856 * Fix typo * Fix bug in transpose Fix python 2 compatibility * Set default for transpose_coords to None Update documentation * Fix bug in coordinate tranpose Update documentation * Suppress FutureWarning in tests * Add restore_coord_dims parameter to DataArrayGroupBy.apply * Move restore_coord_dims parameter to GroupBy class * Remove restore_coord_dims parameter from DataArrayResample.apply * Update whats-new * Update whats-new
I've noticed that
Dataset.transpose
transposes the coordinates whileDataArray.transpose
does not.Example:
This behaviour is probably intentional, but there are cases where I'd like
DataArray.transpose
to also transpose the coordinates. As a workaround, I have to convert to a Dataset, transpose and convert back.I was thinking that
DataArray.transpose
could accept a keyword argumenttranspose_coords
which would beFalse
by default. I could work on a PR implementing this behavior if it's desired.The text was updated successfully, but these errors were encountered: