I have a pandas Dataframe with columns col1 and col2. I am trying to build col3 as:
df["col3"] = (df["col1"] == 1) | (df["col2"] ==1)
and it works. I tried to rewrite it as:
df["col3"] = any([df[c] == 1 for c in ["col1", "col2"]])
but I get the infamous ValueError: The truth value of a series is ambiguous ...
I even tried to rewrite any( .. ) as pd.Series( .. ).any(), but it did not work.
How would you do it?