question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError in categorical factorplot on Python 3.4

See original GitHub issue

It appears that the use of factorplot for categorical data is broken under Python 3.4 and NumPy 1.10. Using an example from the user’s guide:

import seaborn as sb
titanic = sb.load_dataset("titanic")
sb.factorplot("class", data=titanic, palette="PuBuGn_d");

results in the following:

/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numpy-1.10.0.dev_fb898ce-py3.4-macosx-10.10-x86_64.egg/numpy/core/_methods.py in _mean(a, axis, dtype, out, keepdims)
     71         ret = ret.dtype.type(ret / rcount)
     72     else:
---> 73         ret = ret / rcount
     74 
     75     return ret

TypeError: unsupported operand type(s) for /: 'str' and 'int'

Running Seaborn 0.6.dev on OS X 10.10.3.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
mwaskomcommented, Apr 15, 2015

This was part of the updates to categorical plots for 0.6 (by the way this is not well-advertised but the development version is documented here). Because the plots can be drawn horizontally or vertically, you now have to specify kind="count" in factorplot (or use the axes-level countplot function) rather than not passing a quantitative variable.

0reactions
minalb24commented, Nov 30, 2018

Thanks for help…code is working fine 👍

levels=[] # empty list

for level in deck: levels.append(level[0]) # append first letter of data

cabin_df=DataFrame(levels)

cabin_df.columns=[‘Cabin’] # set column =Cabin

sns.factorplot(‘Cabin’,data=cabin_df,palette=‘winter_d’,kind=“count”) # Plot data

cabin_df=cabin_df[cabin_df.Cabin!=‘T’] sns.factorplot(‘Cabin’,data=cabin_df,palette=‘summer’,kind=“count”)

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - unsupported operand type(s) for /: 'str' and 'int'
The factorplot is meant to be used for creating a FacetGrid of plots according to some categorical variables. What you are looking for...
Read more >
Python - seaborn.factorplot() method - GeeksforGeeks
factorplot () method is used to draw a categorical plot onto a FacetGrid. Syntax : seaborn.factorplot(x=None, y=None, hue=None, data=None, row= ...
Read more >
Visualizing categorical data — seaborn 0.12.1 documentation
If one of the main variables is “categorical” (divided into discrete groups) it may be helpful to use a more specialized approach to...
Read more >
Titanic_Buse_EDA - Kaggle
This Python 3 environment comes with many helpful analytics libraries installed ... Categorical Variable Analysis:Survived,Sex,Embarked,Pclass,Cabin,Ticket ...
Read more >
Rotating axis labels in matplotlib and seaborn
Here we have the classic problem with categorical data: we need to display all the labels and because some of them are quite...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found