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

GH1074 Add type hint Series[list[str]] for Series.str.split with expand=False #1075

Merged
merged 8 commits into from
Dec 18, 2024

Conversation

pan-vlados
Copy link
Contributor

@pan-vlados pan-vlados commented Dec 18, 2024

This pull request affect on the issue #571 fixed in pull request #1029.
Drawback is that the next code will be interpreted as type Series[str] (not Series[Any]):

from pandas import Series
baz = Series([])
reveal_type(baz)  # Type of "baz" is "Series[str]"

pandas-stubs/core/series.pyi Outdated Show resolved Hide resolved
pandas-stubs/core/strings.pyi Outdated Show resolved Hide resolved
tests/test_frame.py Outdated Show resolved Hide resolved
    - fix Index.str.split method return wrong result;
    - add test for Index.str.split method with expand=False;
    - return changes performed in pull request pandas-dev#1029.
@pan-vlados pan-vlados requested a review from Dr-Irv December 18, 2024 18:29
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.

Have to admit I was surprised this passed CI as is. Have some other changes to make, but it is looking pretty good.

pandas-stubs/core/strings.pyi Outdated Show resolved Hide resolved
tests/test_indexes.py Outdated Show resolved Hide resolved
tests/test_indexes.py Outdated Show resolved Hide resolved
tests/test_series.py Outdated Show resolved Hide resolved
tests/test_series.py Outdated Show resolved Hide resolved
pan-vlados and others added 5 commits December 18, 2024 22:22
    - combine two str.split overloads and keep only _TS and _TS2;
    - fix test_indexes.py test for test_str_split().
@pan-vlados pan-vlados requested a review from Dr-Irv December 18, 2024 19:34
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.

Almost there. I noticed that you should do rsplit() as well for completeness

pandas-stubs/core/strings.pyi Show resolved Hide resolved
tests/test_indexes.py Outdated Show resolved Hide resolved
@pan-vlados pan-vlados requested a review from Dr-Irv December 18, 2024 20:02
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.

Thanks @pan-vlados

@Dr-Irv Dr-Irv merged commit 109dc86 into pandas-dev:main Dec 18, 2024
10 checks passed
@pan-vlados pan-vlados deleted the issue1070 branch December 18, 2024 21:40
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 type hint for Series containing lists of strings in Series.str.split method with expand=False
2 participants