Fix: pandas series of strings #6158

Merged
merged 1 commit into from Mar 16, 2016

Conversation

Projects
None yet
4 participants
Contributor

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.

mdboom added the needs_review label Mar 15, 2016

@QuLogic QuLogic commented on the diff Mar 15, 2016

lib/matplotlib/cbook.py
@@ -715,6 +715,17 @@ def is_sequence_of_strings(obj):
return True
+def is_hashable(obj):
@QuLogic

QuLogic Mar 15, 2016

Member

Does isinstance(obj, collections.Hashable) not work?

@mdboom

mdboom Mar 15, 2016

Owner

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.

@has2k1 has2k1 Fix: pandas series of strings
*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.
6ef3583

@tacaswell tacaswell added a commit that referenced this pull request Mar 16, 2016

@tacaswell tacaswell Merge pull request #6158 from has2k1/fix-pandas-iterables
Fix: pandas series of strings
2b97396

@tacaswell tacaswell merged commit 2b97396 into matplotlib:master Mar 16, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

tacaswell removed the needs_review label Mar 16, 2016

Owner

tacaswell commented Mar 16, 2016

@has2k1 Thanks!

@tacaswell tacaswell added a commit that referenced this pull request Mar 17, 2016

@tacaswell tacaswell Merge pull request #6158 from has2k1/fix-pandas-iterables
Fix: pandas series of strings
Conflicts:
	lib/matplotlib/collections.py
	  Manually merged changes
c78ca18
Owner

tacaswell commented Mar 17, 2016

backported to v1.5.x as c78ca18

@tacaswell tacaswell added a commit to tacaswell/matplotlib that referenced this pull request May 22, 2016

@tacaswell tacaswell Merge pull request #6158 from has2k1/fix-pandas-iterables
Fix: pandas series of strings
Conflicts:
	lib/matplotlib/collections.py
	  Manually merged changes
a190367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment