Solar Installer Working Percentage (2021)
Problem
Same three DataFrames as the solar-installer activity problem: `installers` (`installer_id`, `onboarded_on`), `requests` (`request_id`, `household_id`, `requested_on`), and `bookings` (`request_id`, `installer_id`, `panel_count`, `job_minutes`).\n\nFor **each of the 12 months of 2021**, report `worked_pct` — the percentage of that month's active installers who actually worked (i.e. were the assigned installer on a booking whose request was made in 2021 in that month). An installer is active from their onboarding month onward (and pre-2021 joiners are active all year). Round to **two decimals**; if no installer is active that month report `0`.\n\nReturn columns `month` (1-12) and `worked_pct`. 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, worked_pct.
Starter code (Pandas (Python))
import pandas as pd
def solar_working_pct(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