-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
cleanup order of operations kludges #19895
Conversation
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.
always rebase on master, the pyarrow issue was resolved yesterday
pandas/core/indexes/datetimes.py
Outdated
@@ -864,11 +864,18 @@ def _add_datelike(self, other): | |||
def _sub_datelike(self, other): | |||
# subtract a datetime from myself, yielding a TimedeltaIndex | |||
from pandas import TimedeltaIndex | |||
|
|||
if isinstance(other, np.ndarray): |
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.
why don't you do this in 873, and just always wrap it
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.
Sounds good.
pandas/core/indexes/timedeltas.py
Outdated
@@ -416,9 +414,15 @@ def _evaluate_with_timedelta_like(self, other, op): | |||
def _add_datelike(self, other): | |||
# adding a timedeltaindex to a datetimelike | |||
from pandas import Timestamp, DatetimeIndex | |||
if isinstance(other, np.ndarray): |
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.
same
@@ -792,7 +792,7 @@ def test_addition_ops(self): | |||
pytest.raises(ValueError, lambda: tdi[0:1] + dti) | |||
|
|||
# random indexes | |||
pytest.raises(TypeError, lambda: tdi + Int64Index([1, 2, 3])) |
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 this an api change?
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.
not sure if it counts as api change or bugfix. The error currently being raises is incorrect.
Codecov Report
@@ Coverage Diff @@
## master #19895 +/- ##
==========================================
- Coverage 91.67% 91.66% -0.01%
==========================================
Files 150 150
Lines 48936 48930 -6
==========================================
- Hits 44860 44853 -7
- Misses 4076 4077 +1
Continue to review full report at Codecov.
|
thanks! |
DatetimeIndexOpsMixin has an unfortunate kludge where it checks if
self
is aTimedeltaIndex
and if so dispatches to a reversed operation. This then makes subsequent checks less straightforward than they could/should be. This fixes that.This is in preparation for separating out DatetimeArray/TimedeltaArray/PeriodArray, so this uses formatting on error messages to be class-agnostic.