mardi 21 avril 2020

IF- ELSE condition based on maximum column value in Python 3 (Jupyter Notebook)

df2=pd.DataFrame(acc,columns = ['Accuracy'],index=['DT','RF','KNN','NN','REG'])
df2=df2.T

This is my dataframe. I want to find which column has the maximum value and perform tasks accordingly.

              DT           RF         KNN         NN         REG
Accuracy    98.882173   99.037636   78.016063   77.240633   54.059435

For example, in the above example, 'RF' has the maximum value. Please help me out with the code in Python 3 . I'm using Jupyter notebook.

Pseudo code:

max= Column name of maximum value ('RF' in this case)

if (max=='RF'):
 ..xyx..
else if (max=='DT'):
 .. abcd...
etc...

Aucun commentaire:

Enregistrer un commentaire