Premium problem91. Average Order Value by Weekday and Hour

Medium Locked

orders has columns order_id, placed_at (datetime) and order_total.

Return a DataFrame with columns weekday, hour and average_total giving the mean order_total for every weekday/hour combination that actually occurs. Number weekdays with Monday as 1 through Sunday as 7. Sort by weekday then hour, and renumber the index from 0.

Input

   order_id           placed_at  order_total
0         1 2022-03-07 09:15:00         20.0
1         2 2022-03-07 09:50:00         30.0
2         3 2022-03-08 18:05:00         45.0
3         4 2022-03-13 12:00:00         10.0

Output

   weekday  hour  average_total
0        1     9           25.0
1        2    18           45.0
2        7    12           10.0

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)