vendredi 6 novembre 2020

if statement for titanic problem not returning anything

dataframe

Trying to count the number of passengers over 20 who had siblings onboard the Titanic. Count siblings/spouses onboard if number is over 1. I created this if statement and added the .all() to avoid the value error the truth value of a series is ambiguous, but it is not printing out anything.

count = []
if (df['Age'].all() >=20) & (df['Siblings/Spouses Aboard'].all() >1):
    count += 1
    print(count)

Aucun commentaire:

Enregistrer un commentaire