Getting Index Name For The Max Value In Df
I have the following dataframe: data = {'Algorithm': ['KNN', 'Decision Tree', 'SVM', 'Logistic Regression'], 'Jaccard': [0.75,0.65,0.67,0.70], 'F1-score': [0.69,0
Solution 1:
Try np.where
:
print(report.index[np.where(report['Jaccard'].max())[0][0]])
Updated Try np.where
:
print(report['Algorithm'][np.where(report['Jaccard'].max())[0][0]])
Or idxmax
:
print(report['Jaccard'].idxmax())
Update:
print(report['Algorithm'][np.where(report['Jaccard']==report['Jaccard'].max())[0][0]])
@jezrael's solution is also very good:
print(report.index[report['Jaccard'] == report['Jaccard'].max()])
Post a Comment for "Getting Index Name For The Max Value In Df"