-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: string methods on empty series (GH7241) #7242
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
Conversation
this will need a release note (though 0.14.1 section is not there yet) |
can u squash to a single commit |
ok |
This is good. I wonder if for consistency perhaps these should return empty Series/DataFRames with object dtype?
|
@@ -578,6 +578,19 @@ def check_index(index): | |||
tm.makeDateIndex, tm.makePeriodIndex ]: | |||
check_index(index()) | |||
|
|||
# GH7241 | |||
# empty series with one group | |||
s = Series(dtype=str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this is equivalent to Series(dtype=object)
.
agreed @wabu can u put in tests for all string methods in empty series (their maybe some already existing) and see what breaks if u enforce object dtype |
It's not necessarily object for all string methods, I guess it should match the dtype of a non-empty example... for example str.count and str.len returns int64 (actually these could be the only examples). |
right those are counting methods so they should be int64 in empty |
sounds like the right thing to do, I'll have a look. |
I changed _na_map. as noted in the release notes, now old:
new:
|
@@ -30,6 +30,9 @@ API changes | |||
- Openpyxl now raises a ValueError on construction of the openpyxl writer | |||
instead of warning on pandas import (:issue:`7284`). | |||
|
|||
- ``StringMethods.extract`` returns series with only NaN values as | |||
``dtype=object`` instead of ``dtype=float`` (:issue:`7242`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe say something about non-matching here (also do need to mention this is str.extract
doc section (basics.rst)? and/or doc-string?
thanks for putting the empty tests together! You have a merge conflict (probably in release notes) so please rebase off master. |
- all StringMethods are tested and work on empty seires - moreover extract always returns dtype==object, even when no match is found
closed via f24f2e8 (there was another merge conflict on the release notes!) |
Thanks! |
closes #7241