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.
count()
will just count number of rows.
sum()
will sum the 1's and 0's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With