samedi 2 octobre 2021

operator sign as variable in python [duplicate]

Below code works: df2 = df.groupby('Column_B')['Column_D'].apply(lambda x: 'Nok' if (x[x < list2[3]].count() > 1) else 'Ok').reset_index(name = 'Cond_1')

If i try to use the operator sign greaterthan or lessthan from a list its showing format errror

df2 = df.groupby('Column_B')['Column_D'].apply(lambda x: 'Nok' if (x[x list[3] list2[3]].count() > 1) else 'Ok').reset_index(name = 'Cond_1')

any idea how we can use the < or > symbols from a list variable 4th row??? say for example list[3] and use in above code note: i'm taking the list from excel where i change it < or > as per need.. and i dont want to disturb the code

Aucun commentaire:

Enregistrer un commentaire