As part of #22811 I added a sort
parameter to the difference
set operation with a default of True
. The other set operations do not have this parameter but some of them sort by default if possible. Should we add a sort
parameter to the other set operations too if possible for consistency?
TODO:
- [x] 0.24.0 DateTimeIndex: union() got an unexpected keyword argument 'sort' #24994
- [x] TimedeltaIndex.intersection has no sort
option. #24966
- [x] Check if we can implement the sort
parameter for RangeIndex.union
(#25788)
- [ ] Decide the sort behaviour when the two Indexes are equal or one of the two Indexes are empty
- [ ] Review all set operation tests and ensure that all corner cases are being tested and that sort behaviour is actually being tested (e.g., pass Indexes that are not already sorted to tests)
- [ ] Implement sort=True
and deprecate sort=None
in future release?
Comment From: jreback
yes sort=True (default for compat) should be added to all set operations
Comment From: reidy-p
Related issues: #17839, #17010, #17378, #17376, #22466
Comment From: reidy-p
@fdroessler As discussed, if you see any other things we need to do to make the implementation of the sort
parameter for set operations consistent describe it in a comment below and I'll add it to the TODO in the top comment in this issue. I'm currently working on implementing sort
for RangeIndex.union
Comment From: YuRenee
It seems that sort=True hasn't been implemented in the recent release version. I tested and got "ValueError: The 'sort' keyword only takes the values of None or False; True was passed." I can try on this issue.
Comment From: jbrockmendel
The set ops all have sort keyword. Closing as complete.