-
-
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
'drop_duplicates' behaves differently when using 1 vs many coordinates for an index #8499
Comments
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! |
FWIW I suspect this behavior is due to the different code-paths that are followed when constructing single-coordinate vs multiple-coordinate indexes in |
To bring more context,
Since However, We need to refactor |
What happened?
I am trying to
drop_duplicates
from a DataArray based on the values of some of the coordinates,starting from a DataArray with coordinates, but no indexes.
To accomplish this, I call 'DataArray.set_xindex' with the appropriate coordinate names,
and then call 'drop_duplicates' on the resulting DataArray, like so:
The above functions as expected; 'good' has had its duplicates dropped,
and we are left with a DataArray of length 2.
However, the following does not function as I would expect:
What did you expect to happen?
I expected
drop_duplicates
to drop the duplicates when I was using only a single coordinate for the index.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: None
python: 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]
python-bits: 64
OS: Linux
OS-release: 5.15.133.1-microsoft-standard-WSL2
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: 4.9.1
xarray: 2023.11.0
pandas: 2.1.0
numpy: 1.24.4
scipy: 1.11.2
netCDF4: 1.6.3
pydap: None
h5netcdf: 1.2.0
h5py: 3.8.0
Nio: None
zarr: None
cftime: 1.6.2
nc_time_axis: None
iris: None
bottleneck: None
dask: 2023.9.1
distributed: 2023.9.1
matplotlib: 3.7.2
cartopy: None
seaborn: 0.12.2
numbagg: None
fsspec: 2023.9.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 68.1.2
pip: 23.2.1
conda: 23.7.3
pytest: 7.4.2
mypy: None
IPython: 8.15.0
sphinx: None
The text was updated successfully, but these errors were encountered: