dimanche 16 mai 2021

Is there any way to handle multiple 'IF' in one line in python? [closed]

keep_cols = df.columns.values.tolist()
If (a == true):
   df[a] = df[x]
   keep_cols.append(a)
If (b == true):
   df[b] = df[y]
   keep_cols.append(b)
If (c == true):
   df[c] = df[z]
   keep_cols.append(c)

#multiple if's with similar checks and similar actions

Aucun commentaire:

Enregistrer un commentaire