Skip to content

DatetimeIndex accessors and reorganize the datetime accessors for Series #212

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 7 commits into from
Aug 20, 2022

Conversation

Dr-Irv
Copy link
Collaborator

@Dr-Irv Dr-Irv commented Aug 20, 2022

Reorganized the accessors to correspond to the pattern used in defining them for DatetimeArray. Used a lot of Generic types and TypeVar to get all the return types right that are different between Series.dt.xxx and DatetimeIndex.xxx for various accessors xxx.

Removed deprecated methods and associated tests.

@Dr-Irv Dr-Irv requested a review from twoertwein August 20, 2022 04:26
@twoertwein
Copy link
Member

wow, we have to do all of this because of inherit_names? I would like to remove inherit_names but it is moving slowly since it also requires implementation changes pandas-dev/pandas#48015

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Aug 20, 2022

wow, we have to do all of this because of inherit_names? I would like to remove inherit_names but it is moving slowly since it also requires implementation changes pandas-dev/pandas#48015

It's really because the way that the properties are hooked in to Series.dt and into DatetimeIndex is via the properties on DatetimeArray , which is using inherit_names so that if you call Series.dt.month or DatetimeIndex.month (for example), it delegates that to DatetimeArray.month, but returns a different result (Series versus Index respectively).

The other option is that we just document all the properties for Series.dt and DatetimeIndex, but that then becomes different than the implementation.

@twoertwein
Copy link
Member

Happy to keep your current approach - it works :) removing inherit_names will take quite a while.

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Aug 20, 2022

Happy to keep your current approach - it works :) removing inherit_names will take quite a while.

Let me know if I should make any other changes.

@twoertwein twoertwein merged commit aab8e66 into pandas-dev:main Aug 20, 2022
@twoertwein
Copy link
Member

Thanks @Dr-Irv hope it becomes easier to type in the future when pandas changes.

@Dr-Irv Dr-Irv deleted the issue194 branch December 28, 2022 15:18
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.

No types for DatetimeIndex attributes
2 participants