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

BUG: iter(Series.str) does not raise a TypeError #54173

Closed
3 tasks done
mroeschke opened this issue Jul 18, 2023 · 1 comment · Fixed by #54174
Closed
3 tasks done

BUG: iter(Series.str) does not raise a TypeError #54173

mroeschke opened this issue Jul 18, 2023 · 1 comment · Fixed by #54174
Labels
Bug Strings String extension data type and string data

Comments

@mroeschke
Copy link
Member

mroeschke commented Jul 18, 2023

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

In [1]: import pandas as pd

In [2]: ser = pd.Series(("google", "wikimedia", "wikipedia", "wikitravel"))

In [3]: list(iter(ser.str)) # hangs

Issue Description

#49268 removed StringMethods.__iter__, but user can still iterate over Series(...).str which indefinitely hangs

Expected Behavior

Raises TypeError

Installed Versions

Replace this line with the output of pd.show_versions()

@dbalagula
Copy link

__getitem__ is used for iterators when __iter__ is not available. One solution would be to implement __iter__ and raise a TypeError, but this isn't simple since it touches two related issues

  • 28277 the resolved issue which caused this one. __iter__ was removed as a result
  • 54176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Strings String extension data type and string data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants