DEPR: DatetimeIndex/PeriodsIndex +/- ops (GH9094) by jreback · Pull Request #9630 · pandas-dev/pandas (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation8 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
deprecate DatetimeIndex/PeriodIndex
+/-
ops which are set ops. In a future version -
will produce a TimeDeltaIndex
and +
a TypeError
surprise surprise, this was not actually tested anywhere AT ALL.
Should the same be done for the other operations?
Eg addition also still does a set operation:
In [12]: dti + dti
Out[12]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-01-01, 2012-01-02]
Length: 2, Freq: D, Timezone: None
Addition is not a usefull operation for datetimes as a numeric operation, but better to be consistent in the fact it will not be a set operation in the future I think.
@jorisvandenbossche yes, dti + dti
should be a TypeError
(in 0.17.0) to be consistent. (as is dti + dt
now). will update.
This should then also close #9095 I think.
hmm, I guess we changed these all to NotImplementedError
(which is actually more correct). but most are still TypeErrors
...hmm
In [3]: pd.date_range('20130101',periods=5)+Timestamp('20140101')
NotImplementedError:
In [4]: pd.date_range('20130101',periods=5)+Timestamp('20140101').to_datetime64()
TypeError: ufunc add cannot use operands with types dtype('<M8[ns]') and dtype('<M8[ns]')
@shoyer IIRC did you change these? (I know you suggested we did....)
jreback changed the title
DEPR: deprecate DatetimeIndex - DatetimeIndex (subtraction) (GH9094) DEPR: DatetimeIndex +/- DatetimeIndex ops (GH9094)
jreback changed the title
DEPR: DatetimeIndex +/- DatetimeIndex ops (GH9094) DEPR: DatetimeIndex/PeriodsIndex +/- ops (GH9094)
NotImplementedError
is wrong -- pd.date_range('20130101',periods=5)+Timestamp('20140101')
should be a TypeError
.
I believe I suggested changing some operations like __add__
to return NotImplemented
, but that's not NotImplementedError
and it's something that the user should never see -- Python should translate it into a TypeError
before it reaches the user.
@shoyer yeh I just looked at the code and everything is tested as a TypeError
, so maybe this odd that it is showing up like this.
this currently represents a set difference operation and should actually
be DTI subtraction to yield a TimeDeltaIndex. Change in a future version.
jreback added a commit that referenced this pull request
DEPR: DatetimeIndex/PeriodsIndex +/- ops (GH9094)
jorisvandenbossche added a commit that referenced this pull request
API/DEPR: Remove +/- as setops for DatetimeIndex/PeriodIndex (GH9630)