solution.py
Python 3
Reset
import pandas as pd import io data = """Date,Category,Product,Units,Revenue 2024-03-01,Hardware,Drill,4,160.00 2024-03-02,Software,License,12,720.00 2024-03-03,Hardware,Saw,3,90.00 2024-03-04,Software,License,8,480.00 2024-03-05,Services,Install,2,250.00 2024-03-06,Hardware,Drill,5,200.00 2024-03-07,Services,Install,1,125.00 2024-03-08,Software,Plugin,20,400.00""" df = pd.read_csv(io.StringIO(data)) # Group by Category and aggregate # Sort by total revenue descending # Print the result
Run
Ctrl+⏎
AI Review
Console