Reputation: 437
I am storing the information about trained models in a DataFrame:
score time
LogisticRegression 1.0 0.257812
RidgeClassifier 1.0 0.283841
RandomForestClassifier 1.0 0.569159
GradientBoostingClassifier 1.0 9.408432
And I need to find the index (name) of the model, which has highest score and shortest time. How do I do that?
Upvotes: 2
Views: 33
Reputation: 18315
sort_values
with ascending one side descending other side:
>>> df.sort_values(["score", "time"], ascending=[False, True]).index[0]
"LogisticRegression"
and get the 0th value in index in the result.
Upvotes: 3