Apologies for the opaque question name (not sure how to word it). I have the following dataframe:
import pandas as pd
import numpy as np
data = [['tom', 1,1,6,4],
['tom', 1,2,2,3],
['tom', 1,2,3,1],
['tom', 2,3,2,7],
['jim', 1,4,3,6],
['jim', 2,6,5,3]]
df = pd.DataFrame(data, columns = ['Name', 'Day','A','B','C'])
df = df.groupby(by=['Name','Day']).agg('sum').reset_index()
df
I would like to add another column that returns text according to which column of A,B,C is the highest:
For example I would like Apple if A is highest, Banana if B is highest, and Carrot if C is highest. So in the example above the values for the 4 columns should be:
New Col
Carrot
Apple
Banana
Carrot
Any help would be much appreciated! Thanks
