Run algorithm
Each step highlights the matching Python line. Program output appears only when a line that prints actually runs.
Ready
| cat | sales |
|---|---|
| A | 100 |
| A | 120 |
| B | 90 |
1import pandas as pd
2df = pd.DataFrame({"cat": ["A","A","B"], "sales": [100,120,90]})
3print(df.groupby("cat")["sales"].mean())
Output: