Instagram
youtube
Facebook
Twitter

Compute Maximum Value of Each Group in Pandas DataFrame

A Compute Maximum Value of Each Group in Pandas DataFrame?
Code Explanation:
● Grouping: Data is grouped using 'Group'.
● Aggregation: Maximum value of each group is calculated with .max().
● Store Result: Stored in group_max.
● Output Display: Maximum values per group are printed.

 

Program:

import pandas as pd

group_max = df.groupby('Group')['Value'].max()

print(group_max)