You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
We may not need to change this in xarray after all -- its seems that the upstream consensus is that alignment operations shouldn't sort by default, and the breaking change in pandas 0.24.x is going to be reverted (see pandas-dev/pandas#24959).
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 nowIndex.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 thatalign()
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:The text was updated successfully, but these errors were encountered: