Skip to content

GH1189/GH1181 Timestamp subtraction and index shift #1191

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

Merged
merged 2 commits into from
Apr 19, 2025

Conversation

loicdiridollou
Copy link
Member

@@ -393,7 +393,7 @@ class Index(IndexOpsMixin[S1]):
def asof_locs(self, where, mask): ...
def sort_values(self, return_indexer: bool = ..., ascending: bool = ...): ...
def sort(self, *args, **kwargs) -> None: ...
def shift(self, periods: int = ..., freq=...) -> None: ...
def shift(self, periods: int = ..., freq=...) -> Self: ...
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small question here, pd.Index.shift is technically not implemented so wondering if it should be NoReturn here and Self for pd.DatetimeIndex, pd.TimedeltaIndex and pd.PeriodIndex or if this is fine as is (technically it would fail at runtime anyway so the typing would not help much to spot the bug).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should take shift() out of here and only include it in the stubs for those 3 types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Thanks for the direction

@@ -393,7 +393,7 @@ class Index(IndexOpsMixin[S1]):
def asof_locs(self, where, mask): ...
def sort_values(self, return_indexer: bool = ..., ascending: bool = ...): ...
def sort(self, *args, **kwargs) -> None: ...
def shift(self, periods: int = ..., freq=...) -> None: ...
def shift(self, periods: int = ..., freq=...) -> Self: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should take shift() out of here and only include it in the stubs for those 3 types.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr-Irv Dr-Irv merged commit 351810b into pandas-dev:main Apr 19, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.Index().shift() claims to return None
2 participants