I have the following code that should put either 0 or 1 into the column INDICATOR depending on if-then rules (values of columns T and S):
rawdata_base['INDICATOR'] = rawdata_base.apply(lambda row:
'1' if row['T']=='2' and str(row['S']).isdigit() and int(row['S'])<15
else '0' if row['T']=='2' and str(row['S']).isdigit() and int(row['S'])>=15
else '1' if row['T']=='1' and str(row['S']).isdigit() and int(row['S'])<35
else '0' if row['T']=='1' and str(row['S']).isdigit() and int(row['S'])>=35
else '0' if 'A' in row['S']
else '0', axis 1)
I cannot figure out why the error invalid syntax pops up at the line else '0', axis 1
Aucun commentaire:
Enregistrer un commentaire