On a Meta product such as Facebook, you are given raw daily monetization events and need to compute a smoothed revenue-per-user trend. Write a function that returns the 7-day rolling average of daily revenue per user (RPU) for each calendar day.
For each event, you are given a date string in YYYY-MM-DD format, a user_id, and a revenue amount. First aggregate events by day to compute:
daily revenue / daily active usersThen compute the 7-day rolling average of daily RPU over the current day and the previous 6 days. If fewer than 7 days exist so far, average over all available days.
Return a list of [date, rolling_average] pairs in ascending date order. Round each rolling average to 2 decimal places.
events, a list of lists where each item is [date, user_id, revenue][date, rolling_average]Example 1
[["2024-01-01","u1",10],["2024-01-01","u2",20],["2024-01-02","u1",30]][["2024-01-01",15.0],["2024-01-02",22.5]]Example 2
[["2024-01-01","u1",5],["2024-01-01","u1",15],["2024-01-02","u2",20]][["2024-01-01",20.0],["2024-01-02",20.0]]1 <= len(events) <= 10^5date is a valid YYYY-MM-DD stringuser_id is a non-empty string0 <= revenue <= 10^6