-
-
Couldn't load subscription status.
- Fork 19.2k
DEPR/BUG: Do not ignore sort in concat for DatetimeIndex #62843
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
base: main
Are you sure you want to change the base?
Conversation
|
@jbrockmendel - this is ready for a look. I still need to look more into the internal usages of |
| When all objects passed to :func:`concat` have a :class:`DatetimeIndex`, | ||
| passing ``sort=False`` will now result in the non-concatenation axis not | ||
| being sorted. Previously, the result would always be sorted along | ||
| the non-concatenation axis even when ``sort=False`` is passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GH ref here to the issue?
|
|
||
|
|
||
| def union_indexes(indexes, sort: bool | None = True) -> Index: | ||
| def union_indexes(indexes, sort: bool | None | lib.NoDefault = True) -> Index: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is None still needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By both type checking and test coverage it looks like no, will remove.
| intersect | ||
| or any(not isinstance(index, DatetimeIndex) for index in non_concat_axis) | ||
| or all( | ||
| id(prev) == id(curr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prev is curr?
I'm fine with this. Though seeing the increased complexity, I'd also be OK with the previous PR's breaking change approach. |
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.Continuation of #62752
There are three things I'd like to accomplish here:
sort=Falseget an unsorted result. This is a bug and should be fixed without deprecation.sortdo not get a change in behavior, but will get warned when enforcing the deprecation will change behavior.concatdoes not break user code.It seems (3) will be very hard to ascertain. There are many places where
concatis used without specifyingsortbut (a) the index cannot be Datetime or (b) alignment has already been done sosorthas no impact. I plan to take a deeper look into internal usage to see if this deprecation can impact other parts of the API, I've so far only found one in groupby.shift that I think we can call a bug.To accomplish these, it seems to me that we need to do a somewhat expensive check to see if not sorting impacts the result as otherwise users will get many spurious warnings.