python - Count no. of specific values in a dataframe pandas -
this question has answer here:
i newbie in data analysis stuff. trying analyse dataset using python.
- i want count no. of 1s in survived column
- no. of male , female in sex column
passengerid survived pclass sex
0 1 0 3 male 1 2 1 1 female 2 3 1 3 male 3 4 1 1 female 4 5 0 3 male
i tried groupby() giving error.
in[88] titanic_data.groupby('survived') out[88] <pandas.core.groupby.dataframegroupby object @ 0x000000000bffe588>
please suggest solution
use value_counts:
df['survived'].value_counts() df['sex'].value_counts()
Comments
Post a Comment