Seaborn: TypeError in categorical factorplot on Python 3.4

Created on 15 Apr 2015  路  5Comments  路  Source: mwaskom/seaborn

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.

Most helpful comment

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.

All 5 comments

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.

Ah, sorry. Will bookmark the dev docs!

thanks mwaskom for your help

Thanks for your help

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")

Was this page helpful?
0 / 5 - 0 ratings