-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed as not planned
Description
I noticed in pandas-dev/pandas#24959 (which turned up as a failure in our test suite) that pandas sorts by default in Index.union
and now Index.intersection
, unless the indexes are the same or either index has duplicates. (These aspects are probably bugs.)
It occurs to me that we should make an intentional choice about sorting in xarray.align()
, rather than merely following the whims of changed upstream behavior. Note that align()
is called internally by all xarray operations that combine multiple objects (e.g., in arithmetic).
My proposal is to use "order of appearance" and not sort by default, but add a sort
keyword argument to allow users to control this. Reasons for the default behavior of not sorting:
- Sorting can't be undone if the original order is lost, so this preserve maximum flexibility for users.
- This matches how we handle the ordering of dimensions in broadcasting.
- Pandas is quite inconsistent with how it applies sorting and we don't want to copy that in xarray. We definitely don't want to sort in all cases by default (e.g., if objects have the same index), so we should avoid sorting in others.
Metadata
Metadata
Assignees
Labels
No labels