-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: PeriodIndex._shallow_copy doesn't roundtrip asi8 values correctly #24391
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
Comments
Definitely weird. @TomAugspurger has worked on this more recently than me. I'll try to take a look over the weekend. |
FYI there is a test that's being xfailed due to this issue, so can remove it when someone has a change to look into this: pandas/pandas/tests/indexes/period/test_period.py Lines 41 to 47 in 159772d
|
The bug seems to be in asfreq (Pdb) values
<PeriodArray>
['2018-01-01', '2018-01-03', '2018-01-05']
Length: 3, dtype: period[2D]
(Pdb) values.asfreq(values.freq)
<PeriodArray>
['2018-01-02', '2018-01-04', '2018-01-06']
Length: 3, dtype: period[2D] Not so much a bug, more how we're calling it. The how='E' means we align the end, but I guess we want start in this case. |
I don't really understand why |
I think the solution is to not pass freq to I don't plan to work on this until DatetimeArray / TimedeltaArray (#24024) are in. I think it'll be easier to fix once those are all consistent. |
On master:
It appears that values are shifted forward by
freq.n - 1
base frequencies, e.g. iffreq='5D'
then the above will result in a shift of'2018-01-01'
-->'2018-01-05'
.Note that this is working on 0.23.4:
cc @jbrockmendel : Am I correct in expecting that
Out[3]
andOut[4]
should be the same?The text was updated successfully, but these errors were encountered: