-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
BUG: PeriodIndex and Period subtraction error #13071
Conversation
hmm, shouldn't subtraction yield a |
Yes returning
|
Also found
|
hmm, actually I think
should be a 2M Span, which we don't really have the concept of. cc @MaximilianR |
I think your first example is legit (you can't do arithmetic between spans and points) but the 2nd should work |
If we think about a Period as a interval / span of time, I think it's reasonable that equal freq Periods can do arithmetic. While Period arithmetic currently return So I think this should probably be a 2M @jreback do you think differently? |
we need a |
I see. But for me it's the same concept, just with different units. So |
so u end up losing freq info here |
Yes, I think this is absolutely right.
Why? |
@MaximilianR 2M doesn't have a fixed conversion because its a relative offset, where as a Timedelta of 60 days is absolute. So you leave something on the table.
|
I don't know the intricacies of In [15]: from dateutil import relativedelta
In [18]: relativedelta.relativedelta(months=2)
Out[18]: relativedelta(months=+2)
In [22]: relativedelta.relativedelta(months=2) + datetime.datetime(2005,5,3)
Out[22]: datetime.datetime(2005, 7, 3, 0, 0) |
|
How about split to 2 separated issues from this:
|
ok on fixing what is broken here. Yes, let's open a new issue to discuss 1) |
msg = _DIFFERENT_FREQ_INDEX.format(self.freqstr, other.freqstr) | ||
raise IncompatibleFrequency(msg) | ||
|
||
if other.ordinal == tslib.iNaT: |
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 always a Period
? see my comment above
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 Period
. Defined in tseries/base.py
.
git diff upstream/master | flake8 --diff
Similar to #5202.
PeriodIndex
subtraction raisesAttributeError
either side isPeriod
(scalar).Expected
If
Period(NaT)
is included in either side, result isFloat64Index
to holdnan
.