TypeError in categorical factorplot on Python 3.4
See original GitHub issueIt 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:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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"
infactorplot
(or use the axes-levelcountplot
function) rather than not passing a quantitative variable.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”)