Cumulative Downloads per Platform
Problem
You are given a DataFrame `dailyinstalls` with columns `app_name`, `platform`, `log_day`, and `installs`. The pair `(platform, log_day)` is unique, and each row gives the number of installs recorded for an app on a given platform (such as 'iOS' or 'Android') on a given day.
For each platform and each day, report the **running total of installs** on that platform up to and including that day. Name the running total `cumulative_installs`.
Return `platform`, `log_day`, and `cumulative_installs`, ordered by `platform`, then by `log_day`.
**Example**
```text
dailyinstalls:
+----------+----------+------------+----------+
| app_name | platform | log_day | installs |
+----------+----------+------------+----------+
| Lumio | iOS | 2022-05-01 | 100 |
| Pixly | Android | 2022-05-01 | 50 |
| Lumio | iOS | 2022-05-02 | 30 |
| Pixly | Android | 2022-05-02 | 40 |
+----------+----------+------------+----------+
Result:
+----------+------------+---------------------+
| platform | log_day | cumulative_installs |
+----------+------------+---------------------+
| Android | 2022-05-01 | 50 |
| Android | 2022-05-02 | 90 |
| iOS | 2022-05-01 | 100 |
| iOS | 2022-05-02 | 130 |
+----------+------------+---------------------+
```
Input data
Example rows — the live problem includes the full dataset.
| app_name | platform | log_day | installs |
|---|---|---|---|
| Lumio | iOS | 2022-05-01 | 100 |
| Pixly | Android | 2022-05-01 | 50 |
| Lumio | iOS | 2022-05-02 | 30 |
| Pixly | Android | 2022-05-02 | 40 |
Expected output
Your answer should return 4 rows with the columns platform, log_day, cumulative_installs.
Starter code (Pandas (Python))
import pandas as pd
def cumulative_downloads_per_platform(dailyinstalls) -> pd.DataFrame:
# Your code here
return dailyinstallsSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock