In the DataFrame
import pandas as pd
df=pd.DataFrame({\'col1\':[1,2,3],\'col2\':[3,2,1],\'col3\':[1,1,1]},index= [\'row1\',\'row2\',\'row3\'])
print df
you could also use apply and create a method such has:
def returncolname(row, colnames):
return colnames[np.argmax(row.values)]
df['colmax'] = df.apply(lambda x: returncolname(x, df.columns), axis=1)
Out[62]:
row1 col2
row2 col1
row3 col1
dtype: object
an you can use df.max(axis=1) to extract maxes
df.max(axis=1)
Out[69]:
row1 3
row2 2
row3 3