Solar Installer Monthly Activity (2021)
Problem
A solar-panel company keeps three DataFrames. `installers` (`installer_id`, `onboarded_on`) records when each installer joined. `requests` (`request_id`, `household_id`, `requested_on`) records install requests from households. `bookings` (`request_id`, `installer_id`, `panel_count`, `job_minutes`) records each request that was actually booked to an installer.\n\nFor **each of the 12 months of 2021**, report two numbers:\n- `active_installers` — installers considered active that month: anyone onboarded before 2021, plus anyone onboarded in 2021 in that month or earlier (an installer is active from their onboarding month onward, and forever after).\n- `booked_requests` — the number of bookings whose underlying request was made in 2021 in that month.\n\nReturn columns `month` (1-12), `active_installers`, `booked_requests`. Rows may be in any order.
Input data
Example rows — the live problem includes the full dataset.
| installer_id | onboarded_on |
|---|---|
| 10 | 2020-12-10 |
| 8 | 2021-01-13 |
| 5 | 2021-02-16 |
| 7 | 2021-03-08 |
| 4 | 2021-05-17 |
| request_id | household_id | requested_on |
|---|---|---|
| 6 | 75 | 2020-12-09 |
| 1 | 54 | 2021-02-09 |
| 10 | 63 | 2021-03-04 |
| 19 | 39 | 2021-04-06 |
| 3 | 41 | 2021-06-03 |
| request_id | installer_id | panel_count | job_minutes |
|---|---|---|---|
| 10 | 10 | 63 | 38 |
| 13 | 10 | 73 | 96 |
| 7 | 8 | 100 | 28 |
| 17 | 7 | 119 | 68 |
| 20 | 1 | 121 | 92 |
Expected output
Your answer should return 12 rows with the columns month, active_installers, booked_requests.
Starter code (Pandas (Python))
import pandas as pd
def solar_monthly_activity(installers, requests, bookings) -> pd.DataFrame:
# Your code here
return installersSolve 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