Reformat Department Table
revenue has columns id (a department), month ("Jan", "Feb" or "Mar") and amount. A department can have several rows for the same month. Return a DataFrame with the columns id, Jan, Feb and Mar holding each department's total amount per month (0 when there is none), ordered by id.
Example 1
revenue {"id":[1,1,2],"month":["Jan","Mar","Feb"],"amount":[10,5,7]}
returns {"columns":["id","Jan","Feb","Mar"],"rows":[[1,10,0,5],[2,0,7,0]]}
Department 1: Jan 10, Mar 5. Department 2: Feb 7.
Constraints
- The tables are small
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Revenue per ProductMedium
- Rising TemperatureMedium
- Salespeople Without Red OrdersMedium
- Three in a RowMedium
- Top Earners per DepartmentMedium
- Two Best per TeamMedium
- Visits per UserMedium
- Bought Together MostHard