max()
df.groupby(column_name).max()
Returns a DataFrame, with rows as groups, and each column as the max of the column values within each group.
- Note:
- Columns with String values display the maximum alphabetical starting character (ex.
"white"is alphabetically after"black"and"golden").
pets
| Index | Species | Color | Weight | Age |
|---|---|---|---|---|
| 0 | dog | black | 40 | 5 |
| 1 | cat | golden | 15 | 8 |
| 2 | cat | black | 20 | 9 |
| 3 | dog | white | 80 | 2 |
| 4 | dog | black | 25 | 0.5 |
| 5 | hamster | black | 1 | 3 |
| 6 | hamster | golden | 0.25 | 0.2 |
pets.groupby('Species').max()
| Index | ID | Color | Weight | Age | Is_Cat | Owner_Comment |
|---|---|---|---|---|---|---|
| cat | cat_003 | golden | 15 | 9 | True | No, thank you! |
| dog | dog_003 | white | 80 | 5 | False | Love is a wet nose and a wagging tail. |
| hamster | ham_002 | golden | 1 | 3 | False | No, thank you! |
Problems or suggestions about this page? Fill out our feedback form.