简体   繁体   English

不能 plot 由 seaborn 联合绘制 - 如何?

[英]Cannot plot a jointplot by seaborn-How to?

I am trying to plot a Smoker vs Region data through Seaborn.我正在尝试通过 Seaborn plot 吸烟者与地区数据。 the smoker was first a type of object which i converted to int.吸烟者首先是一种 object,我将其转换为 int。 although i am getting an error.虽然我得到一个错误。 I am not sure how to plot it.我不确定如何 plot 它。

I have already tried converting the object into int but still its not displaying the graph.我已经尝试将 object 转换为 int 但它仍然没有显示图表。

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'"我在最后一行收到一个错误,例如“TypeError:不能将序列乘以'float'类型的非整数”

jointplot working with both numeric columns, so here is batter another solution - seaborn.swarmplot : jointplot使用两个数字列,所以这是另一种解决方案 - seaborn.swarmplot

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM