pd.notnull pd.isnull transpose

Survived_cabin = data_train.Survived[pd.notnull(data_train.Cabin)].value_counts()
Survived_nocabin = data_train.Survived[pd.isnull(data_train.Cabin)].value_counts()
df=pd.DataFrame({u'':Survived_cabin, u'':Survived_nocabin}).transpose()
df.plot(kind='bar', stacked=True)
plt.title(u"按Cabin有无看获救情况")
plt.xlabel(u"Cabin有无") 
plt.ylabel(u"人数")
plt.show()

 

请使用手机"扫一扫"x

posted @ 2018-07-30 21:30  菜鸟key  阅读(238)  评论(0编辑  收藏  举报