-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Calling shift on a DatetimeIndex of length 0 returns an Index instead of a DatetimeIndex #9903
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
(This happens because DatetimeIndex delegates to Index.shift, which then calls the Index.new with an empty list, and it can't infer that the output should be a DatetimeIndex.) |
Fixes a bug where calling shift on an empty DatetimeIndex would result in the returned value being an Index rather than a DatetimeIndex.
This is fixed by #9904. |
Fixes a bug where calling shift on an empty DatetimeIndex would result in the returned value being an Index rather than a DatetimeIndex.
Fixes a bug where calling shift on an empty DatetimeIndex would result in the returned value being an Index rather than a DatetimeIndex.
This has been already fixed in current master (maybe by #11211?). Adding tests then close. |
@sinhrks looks good.
I since we have 0 len we don't infer the freq, but in this case we know the freq (as we are shifting by it), or is that too much carry-over? |
|
cc @ssanderson |
@sinhrks no, I was more thinking that If I shift an index, then I want to have it set the freq (as opposed to infer it which won't work if its < 3 elements). not really strong here opinion here, except that this was from a user action. |
@jreback I don't think that shifting an index by a specific frequency should be taken to imply that the index's data has that frequency. If I have an hourly-frequency index, and I shift it forward by 5 minutes, it's still hourly frequency. That doesn't change if my index is empty. |
@ssanderson hmm, that is right. ok then! |
Minimal repro:
The text was updated successfully, but these errors were encountered: