Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Mar 16, 2016

Conversation

has2k1
Copy link
Contributor

@has2k1 has2k1 commented Mar 15, 2016

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.

@@ -715,6 +715,17 @@ def is_sequence_of_strings(obj):
return True


def is_hashable(obj):
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tacaswell tacaswell added this to the 1.5.2 (Critical bug fix release) milestone Mar 15, 2016
@has2k1 has2k1 force-pushed the fix-pandas-iterables branch from 84173a4 to 98a201a Compare March 15, 2016 19:56
*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.
@has2k1 has2k1 force-pushed the fix-pandas-iterables branch from 98a201a to 6ef3583 Compare March 15, 2016 20:51
tacaswell added a commit that referenced this pull request Mar 16, 2016
@tacaswell tacaswell merged commit 2b97396 into matplotlib:master Mar 16, 2016
@tacaswell
Copy link
Member

@has2k1 Thanks!

tacaswell added a commit that referenced this pull request Mar 17, 2016
Fix: pandas series of strings
Conflicts:
	lib/matplotlib/collections.py
	  Manually merged changes
@tacaswell
Copy link
Member

backported to v1.5.x as c78ca18

tacaswell added a commit to tacaswell/matplotlib that referenced this pull request May 22, 2016
Fix: pandas series of strings
Conflicts:
	lib/matplotlib/collections.py
	  Manually merged changes
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.

4 participants