Skip to content
CampusEduX

Group Sales by Region

Mediumpython
Learn the Concept: Data Analysis (NumPy, Pandas, Matplotlib, Seaborn)

Given sales data with region and amount columns, group by region and calculate the total sales per region.

Approach: build the DataFrame, then df.groupby("region")["amount"].sum(), ordered by region name for a predictable result.

Input: First line: the number of sales records n. Next n lines: region,amount.

Output: One line per region: a tuple (region, total), ordered alphabetically by region.

Related Problems

Input (stdin)

Output

Run your code to see output here...