Skip to content
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

Create __iter__() for DatetimeIndex #723

Closed
Dr-Irv opened this issue Jun 1, 2023 · 3 comments · Fixed by #760
Closed

Create __iter__() for DatetimeIndex #723

Dr-Irv opened this issue Jun 1, 2023 · 3 comments · Fixed by #760
Labels
Index Related to the Index class or subclasses Timestamp Cod related to pd.Timestamp

Comments

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Jun 1, 2023

I also ran in to this using date_range.

Workaround is good for now:

for ts in cast(Iterator[datetime], date_range(start='1/1/2023', end='1/08/2023', freq='6H', tz=timezone.utc)):
   ....

Originally posted by @davetapley in #502 (comment)

Should create DatetimeIndex.__iter__() returning Timestamp

@Dr-Irv Dr-Irv added Index Related to the Index class or subclasses Interval Interval data type Timestamp Cod related to pd.Timestamp and removed Interval Interval data type labels Jun 1, 2023
@twoertwein
Copy link
Member

twoertwein commented Aug 2, 2023

Is there a reason that IndexOpsMixin is not generic (except for it taking quite some work)? Pandas seems to define __iter__ on IndexOpsMixin. I have locally a branch that tries to make IndexOpsMixin generic. If I get it to work, I will open a PR.

edit: https://github.com/twoertwein/pandas-stubs/tree/iter_interpolate

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Aug 2, 2023

Is there a reason that IndexOpsMixin is not generic (except for it taking quite some work)?

Historical artifact of how the stubs were created. I hope you can get this to work!

@twoertwein
Copy link
Member

I created #760 - still needs some time to be ready but it is getting there. Feel free to skim it to see if something could clearly be better :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Timestamp Cod related to pd.Timestamp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants