我正在用这个codecademy: data处理一个小数据帧
我正在尝试打印数据,以便使用以下代码进行小型分析:
data = pd.read_csv('insurance.csv')
age sex bmi children smoker region charges
0 19 female 27.900 0 yes southwest 16884.92400
1 18 male 33.770 1 no southeast 1725.55230
2 28 male 33.000 3 no southeast 4449.46200
3 33 male 22.705 0 no northwest 21984.47061
4 32 male 28.880 0 no northwest 3866.85520
data.groupby('sex').region.hist()
代码返回一个系列,其中第一个元素是subplot1,第二个是subplot2
代码将它们绘制在同一个图形上,我无法单独绘制它们
'children'
和'smoker'
看起来不同,因为数字是离散的,分别只有6个和2个唯一值李>data.groupby('sex').hist(layout=(1, 4), figsize=(12, 4), ec='k', grid=False)
将单独生成图形,但没有添加标题的简单方法李>python 3.8.11
、pandas 1.3.2
、matplotlib 3.4.2
、seaborn 0.11.2
data.groupby('sex').region.hist()
,这是一个计数图,显示每个地区的性别计数;这不是直方图李>使用^{}
相关问题 更多 >
编程相关推荐