我正在研究泰坦尼克号的数据集,我从这个网站上得到它: https://public.opendatasoft.com/explore/dataset/titanic-passengers/table/?flg=fr
我想显示每个幸存班级的男女人数(是或否)
首先,我得到了男性和女性的总数,使用:
bysex=data1['Sex'].value_counts()
print(bysex)
这给了我这些结果:
male 577
female 314
Name: Sex, dtype: int64
结果表明,男性人数多于女性
但当我使用seaborn来显示每个幸存类的男性和女性人数时,使用以下代码:
plot1 = sns.FacetGrid(data1, col='Survived')
plot1.map(sns.countplot,'Sex')
然后我得到这个结果: enter image description here
在这里,它表明女性的数量大于男性的数量,对于没有幸存的阶级来说,女性的数量(大约450人)甚至大于女性的总数(314人)
这怎么可能
我认为地图有问题。 在左边的情节中,性别互换
第二个情节是对的
另一方面,当你使用
你得到了正确的结果
相关问题 更多 >
编程相关推荐