html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/7294#issuecomment-1326823221,https://api.github.com/repos/pydata/xarray/issues/7294,1326823221,IC_kwDOAMm_X85PFbc1,14808389,2022-11-24T20:39:03Z,2022-11-24T20:40:32Z,MEMBER,"`transpose_coords` is used to transpose coordinates with multiple dimensions: ```python In [1]: import xarray as xr ...: ...: ds = xr.tutorial.open_dataset(""rasm"") ...: ds.Tair.attrs.clear() ...: ds.Tair Out[1]: [2029500 values with dtype=float64] Coordinates: * time (time) object 1980-09-16 12:00:00 ... 1983-08-17 00:00:00 xc (y, x) float64 ... yc (y, x) float64 ... Dimensions without coordinates: y, x In [2]: ds.Tair.transpose(""x"", ""y"", ..., transpose_coords=False) Out[2]: [2029500 values with dtype=float64] Coordinates: * time (time) object 1980-09-16 12:00:00 ... 1983-08-17 00:00:00 xc (y, x) float64 ... yc (y, x) float64 ... Dimensions without coordinates: x, y In [3]: ds.Tair.transpose(""x"", ""y"", ..., transpose_coords=True) Out[3]: [2029500 values with dtype=float64] Coordinates: * time (time) object 1980-09-16 12:00:00 ... 1983-08-17 00:00:00 xc (x, y) float64 ... yc (x, y) float64 ... Dimensions without coordinates: x, y ``` Interestingly, `transpose_coords` is only an option for `DataArray.transpose`, and it defaults to `True`. This means that the example from https://github.com/pydata/xarray/issues/7294#issue-1452123685 always does the same thing, so even if we *did* implement the reordering nothing would change. As such, I'm -0.5 on changing the order in which the coordinates are stored, since the only time that order is used is the `repr` / HTML `repr`. In the past we have actually considered *sorting* the coordinates alphabetically, which did not happen because the coordinate names can be hashables of arbitrary types, and comparing a pair of hashables of different types is not easy.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1452123685 https://github.com/pydata/xarray/issues/7294#issuecomment-1326809036,https://api.github.com/repos/pydata/xarray/issues/7294,1326809036,IC_kwDOAMm_X85PFX_M,43316012,2022-11-24T20:07:47Z,2022-11-24T20:07:47Z,COLLABORATOR,"Just noticed that the same logic does not work for Datasets, since all variables are kept in a common dict and the information about which are coordinates and which are data-variables is kept in a set, which is not ordered...","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1452123685 https://github.com/pydata/xarray/issues/7294#issuecomment-1326804904,https://api.github.com/repos/pydata/xarray/issues/7294,1326804904,IC_kwDOAMm_X85PFW-o,43316012,2022-11-24T19:59:42Z,2022-11-24T19:59:42Z,COLLABORATOR,"The logic for this is not really trivial unless I am missing some obvious trick. You basically have to change the loop here: https://github.com/pydata/xarray/blob/ff6793d975ef4d1d8d5d32b8ad6f4f44e02dda9b/xarray/core/dataarray.py#L2919 To loop first over the new dims and potential coordinates with the same name and then over the rest of the coordinates (If possible in a single loop without code repetition). Feel free to propose a PR!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1452123685 https://github.com/pydata/xarray/issues/7294#issuecomment-1325699317,https://api.github.com/repos/pydata/xarray/issues/7294,1325699317,IC_kwDOAMm_X85PBJD1,43316012,2022-11-23T21:48:28Z,2022-11-23T21:48:28Z,COLLABORATOR,And what should happen with non-dimension coordinates? Should they simply end up in the end?,"{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1452123685 https://github.com/pydata/xarray/issues/7294#issuecomment-1317593352,https://api.github.com/repos/pydata/xarray/issues/7294,1317593352,IC_kwDOAMm_X85OiOEI,34257249,2022-11-16T19:57:40Z,2022-11-16T19:57:40Z,CONTRIBUTOR,"Thanks. On one hand I see your point: a mapping does not ensure order. On the other hand, is it not counter-intuitive that the order of the dictionary-like container coords is not changed when using `transpose_coords=True`? Here my reasoning: - dictionaries maintain insertion order - coords are a [""Dictionary-like container""](https://docs.xarray.dev/en/stable/generated/xarray.DataArray.coords.html) - [a coords dict is created when `transpose_coords==True`](https://github.com/pydata/xarray/blob/main/xarray/core/dataarray.py#L2917-L2918) - would it not be the right time, during insertion, to create the proper order? ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1452123685 https://github.com/pydata/xarray/issues/7294#issuecomment-1317531894,https://api.github.com/repos/pydata/xarray/issues/7294,1317531894,IC_kwDOAMm_X85Oh_D2,43316012,2022-11-16T19:07:00Z,2022-11-16T19:07:13Z,COLLABORATOR,"The coordinates are just a mapping from names to DataArrays, I don't think the order has any meaning (like it does for normal dicts).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1452123685