I'm trying find max value between three columns, but I get the error (The truth value of a Series is ambiguous).
I have a dataframe like this:
| TR0 | TR1 | TR2 | TR |
|---|---|---|---|
| 3.25 | 2.19 | 0.15 | |
| 3.0 | 0 | 0.14 |
I need put in column "TR" the max value between columns TR0, TR1, TR2. I'm trying this:
df.loc[:,'TR'] = max(df.loc[:,'TR0'], df.loc[:,'TR1'], df.loc[:,'TR2'])
but get the message The truth value of a Series is ambiguous
The problem is your using the Python max function with Pandas series as arguments. It was not designed for that.
Use the Pandas data frame max method instead: