Articles → Pandas → Idxmax Function In Pandas
Idxmax Function In Pandas
Purpose
Example
import pandas as pd
df = pd.DataFrame({"A": [4, 5, 2, 6], "B": [11, 2, 5, 8], "C": [1, 8, 66, 4]})
print(df.idxmax())
- In the first row, 6 is the maximum number and its index is 3.
- In the second row, 11 is the maximum number and its index is 0.
- In the third row, 66 is the maximum number and its index is 2.
Output
Click to Enlarge