I have a simple dataframe with two columns: "Sex" and "Alive". What I want to do is to count how many of each gender has survived (indicated by 1 in the file). Here's my file:
Sex Alive
male 1
male 0
female 1
female 1
I tried using the following code, but it has not worked. Any hints and pointers is greatly appreciated.
for r in df:
if [ (df.Sex=='male') & (df.Alive==1) ]:
male_survival_rate += 1
else:
male_dead_rate += 1
Aucun commentaire:
Enregistrer un commentaire