%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv('result.csv')
data.head(2)
plt.figure(figsize=(4,4),dpi=100)
plt.bar(list(Sex_data.index),list(Sex_data.Survived),width=0.2)
plt.title('survived_count')
plt.show()
男女生存人数:
text.groupby('Sex')['Survived'].sum()
先按性别再按新村,count计数
data.groupby(['Sex','Survived'])[['Survived']].count()
data.groupby(['Sex','Survived'])['Survived'].count().unstack()
先根据不同仓位分组:
pclass_sur = text.groupby(['Pclass'])['Survived'].value_counts()
pclass_sur
facet = sns.FacetGrid(text, hue="Survived",aspect=3)
facet.map(sns.kdeplot,'Age',shade= True)
facet.set(xlim=(0, text['Age'].max()))
facet.add_legend()
散点图