issues: 1452123685
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1452123685 | I_kwDOAMm_X85WjaYl | 7294 | DataArray.transpose with transpose_coords=True does not change coords order | 34257249 | open | 0 | 6 | 2022-11-16T19:02:27Z | 2022-11-24T20:40:32Z | CONTRIBUTOR | What happened?I used DataArray.transpose with The order of dims was correctly transposed but the order of coords remained unchanged. What did you expect to happen?I expected the transposed coords to be in the new order:
Minimal Complete Verifiable Example```Python import numpy as np import pandas as pd import xarray as xr np.random.seed(0) temperature = np.random.randn(4, 4, 3) dim_0_values = [1, 2, 3, 4] dim_1_values = [5, 6, 7, 8] dim_2_values = pd.date_range("2014-09-06", periods=3) starting_dims = "dim_0", "dim_1", "dim_2" da = xr.DataArray( data=temperature, dims=starting_dims, coords=dict( dim_0=dim_0_values, dim_1=dim_1_values, dim_2=dim_2_values, ), attrs=dict( description="Ambient temperature.", units="degC", ), ) print(f"{da.dims=}") print(f"{da.coords.keys()=}") reordered_dims = "dim_2", "dim_1", "dim_0" print(f"{da.transpose(reordered_dims).dims=}") print(f"{da.transpose(reordered_dims).coords.keys()=}") print(f"{da.transpose(*reordered_dims, transpose_coords=True).coords.keys()=}") ``` MVCE confirmation
Relevant log output
Anything else we need to know?No response Environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 85 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('English_United States', '1252')
libhdf5: 1.10.6
libnetcdf: None
xarray: 2022.6.0
pandas: 1.4.2
numpy: 1.21.5
scipy: 1.9.3
netCDF4: None
pydap: None
h5netcdf: None
h5py: 3.6.0
Nio: None
zarr: 2.13.2
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.4
dask: 2022.02.1
distributed: 2022.2.1
matplotlib: 3.5.1
cartopy: None
seaborn: 0.11.2
numbagg: None
fsspec: 2022.02.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 61.2.0
pip: 22.3.1
conda: 4.12.0
pytest: 7.1.1
IPython: 8.2.0
sphinx: 4.4.0
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7294/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |