data = {'name' : ['bill', 'joe', 'steve'], 'test1' : [85, 75, 85], 'test2' : [35, 45, 83], 'test3' : [51, 61, 45]} frame = pd.DataFrame(data)
I would like to add a new column that shows the maximum value for each row.
desired result:
name test1 test2 test3 HighScore bill 75 75 85 85 joe 35 45 83 83 steve 51 61 45 61
Sometimes
frame['HighScore'] = max(data['test1'], data['test2'], data['test3'])
works, but most of the time gives this error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any () or a.all ()
Why does it work only occasionally? Is there any other way to do this?
user2333196 Nov 17 '13 at 16:22 2013-11-17 16:22
source share