Cannot plot a jointplot by seaborn-How to?

Viewed 147

I am trying to plot a Smoker vs Region data through Seaborn. the smoker was first a type of object which i converted to int. although i am getting an error. I am not sure how to plot it.

I have already tried converting the object into int but still its not displaying the graph.

here's my code.

import pandas as pd
import seaborn as sns

data = pd.read_csv('insurance.csv')
print(data.head(10))
print('Before changing datadrame',data.info())
data1 = pd.DataFrame(data, columns = ['age','sex','bmi','children','smoker','region','charges'])
data1['smoker'] = data1['smoker'].map({'yes': 1, 'no': 0})
print(data1.head(10))
print('After changing dataframe', data1.info())
print(sns.jointplot(data1['smoker'],data1['region']))

I am getting an error on the last line like "TypeError: can't multiply sequence by non-int of type 'float'"

1 Answers

jointplot working with both numeric columns, so here is batter another solution - seaborn.swarmplot:

sns.swarmplot(data1['smoker'],data1['region'])
Related