Can you help me understand the difference between the statements mentioned below? Given that Survived
column contains binary data (0,1), they give different answers:
df_train[df_train.Sex == 'female'].Survived.count()
df_train[df_train.Sex == 'female'].Survived.sum()
sum()
is for like 1+0 = 1
. if data is 3
and 3
then it will return 6
.
count()
return number of rows, so it will return 2.