-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix: pandas series of strings #6158
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
@@ -715,6 +715,17 @@ def is_sequence_of_strings(obj): | |||
return True | |||
|
|||
|
|||
def is_hashable(obj): |
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.
Does isinstance(obj, collections.Hashable)
not work?
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.
That only works for built-in types or types that explicitly use the collections.Hashable
abc. This implementation is more "duck-typing" style and therefore includes more things.
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.
e.g. numpy/numpy#5562
84173a4
to
98a201a
Compare
*Problem* Pandas series of strings exhibits string like behaviour and it was being treated as a single string. *Solution* When requiring and identifying a single string, make sure that the object can be hashed. This screens out the series and lets them get rightly handled as sequences.
98a201a
to
6ef3583
Compare
Fix: pandas series of strings
@has2k1 Thanks! |
Fix: pandas series of strings Conflicts: lib/matplotlib/collections.py Manually merged changes
backported to v1.5.x as c78ca18 |
Fix: pandas series of strings Conflicts: lib/matplotlib/collections.py Manually merged changes
Problem
Pandas series of strings exhibits string like behaviour
and it was being treated as a single string.
Solution
When requiring and identifying a single string, make sure
that the object can be hashed. This screens out the
series and lets them get rightly handled as sequences.