df = pd.DataFrame({"A": [1, 2, 3, 4, 5, 6], "B": [100, 200, 300, 400, 500, 600]}) # Forma 1 df.loc[((df.A == 1) | (df.A == 2)) & ((df.B == 600) | (df.B == 200)), "C"] = "1or2and600or200" # Forma 2 df.loc[df.A.isin([1, 2]) & df.B.isin([600, 200]), 'C'] = "1or2and600or200"
Comentários