A school keeps students with the columns id and name, and marks with the columns student_id, subject, and mark: one row per mark.
The head teacher wants to know how many marks each student has, listed by the student's name. Work it out from students and marks, assign it to report, and print report.
A courier scans parcels three times a day. morning, noon, and evening each have the columns parcel and kg.
The depot manager wants one table with every scan of the day, in time order, with the rows numbered 0, 1, 2, ... and no number used twice. Build it from morning, noon, and evening, assign it to report, and print report.
A taxi firm keeps one table of trips per week. Each table has the columns driver and km: one row per trip.
The owner wants to reward the driver who made the most trips over two weeks. Write a function named busiest_driver that takes the week tables week1 and week2 and returns that driver's name.
>>> week1 = pd.DataFrame({"driver": ["Raj", "Lea"], "km": [12, 5]})
>>> week2 = pd.DataFrame({"driver": ["Raj", "Femi", "Raj"], "km": [7, 30, 9]})
>>> busiest_driver(week1, week2)
'Raj'
Create a Series from [9, 2, 7] and assign it to s.
Sort the values of s, assign the result to ordered, and print ordered.
Write a function named ware_lek that takes a table df and a ware ware and returns the total lek for that ware.
>>> ware_lek(pd.DataFrame({"ware": ["cup", "jug", "cup"], "lek": [8, 25, 4]}), "cup")
12
Write a function named over_n that takes a table df, a ware ware, and a number n, and returns whether the total lek for that ware is greater than n. over_n must use ware_lek.
>>> over_n(pd.DataFrame({"ware": ["cup", "jug", "cup"], "lek": [8, 25, 4]}), "cup", 10)
True
Write a function named to_wide that takes a table df and pivots year into columns using lek.
>>> to_wide(pd.DataFrame({"ware": ["lid", "lid"], "year": [2020, 2021], "lek": [15, 8]}))
year 2020 2021
ware
lid 15 8
A bakery keeps two tables. orders has the columns order, client, and lek: one row per order. clients has the columns name and city: where each client lives. Some clients have no orders yet.
The courier wants each order together with the city to deliver it to. Build it from orders and clients, assign it to report, and print report.
|  Put two branches' parcels in one list | ||
|  Add each parcel's zone from the zone list | ||
|  Count parcels per city | ||
|  Show each order with the client's city |
df is a table of kit prices.
For each ware and year of df, take the sum of lek, assign the result to totals, and print totals.
Write a function named city_kg that takes a table df and a city city and returns the sum of kg for that city.
>>> df = pd.DataFrame({"city": ["Kyoto", "Accra", "Kyoto"], "kg": [9, 4, 6]})
>>> city_kg(df, "Kyoto")
15
Write a function named over_n that takes df, city, and a number n and returns whether that city's kg sum is greater than n. It must use city_kg.
>>> df = pd.DataFrame({"city": ["Rio", "Hanoi"], "kg": [5, 2]})
>>> over_n(df, "Rio", 4)
True