I have a dataframe df like this:
| region | model | metrics |
|---|---|---|
| Tokyo | ARIMA | 0.1 |
| Tokyo | FeedForward | 0.2 |
| Tokyo | DeepAR | 0.3 |
| Osaka | ARIMA | 0.5 |
| Osaka | FeedForward | 0.2 |
| Osaka | DeepAR | 0.1 |
I want to group this by region and return the minimum value of metrics in each group, as well as the model value where the metrics is minimum.
The expected result:
| region | model | metrics|
| -------- | --------- |----|
| Tokyo | ARIMA |0.1|
| Osaka | DeepAR |0.1|
I tried to do it like below, but not sure how I can complete:
df.groupby("region").agg({'metrics':'min', ####... })
Maybe use argmin? Any help will be appreciated. Thanks!