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. enter image description here

  1. i want count no. of 1s in survived column
  2. 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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -