[FEA] Series and DataFrame idxmax and idxmin
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
For API compatibility, cuDF should support [idxmax](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.idxmax.html) and [idxmin](https://pandas.pydata.org/docs/reference/api/pandas.Series.idxmax.html) on Series and DataFrames.
Note that argmin and argmax (https://github.com/rapidsai/cudf/issues/9601) are slightly different from idxmin and idxmax. The latter methods return the index label associated with the first occurrence of the minimum or maximum value. The index label may not be an integer (see example below).
On DataFrmes, these methods return a Series in which each row corresponds to one column in the original dataFrame.
```python
import pandas as pd
df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
'co2_emissions': [37.2, 19.66, 1712]},
index=['Pork', 'Wheat Products', 'Beef'])
print(df, "\n")
print(df.idxmax(), "\n")
print(df.idxmin())
consumption co2_emissions
Pork 10.51 37.20
Wheat Products 103.11 19.66
Beef 55.48 1712.00
consumption Wheat Products
co2_emissions Beef
dtype: object
consumption Pork
co2_emissions Wheat Products
dtype: object
```
```python
import pandas as pd
df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
'co2_emissions': [37.2, 19.66, 1712]})
print(df, "\n")
print(df.idxmax(), "\n")
print(df.idxmin())
consumption co2_emissions
0 10.51 37.20
1 103.11 19.66
2 55.48 1712.00
consumption 1
co2_emissions 2
dtype: int64
consumption 0
co2_emissions 1
dtype: int64
```
Contributor guide
Assessment
This issue has not been assessed yet.