AnalystPath

Solar Installer Working Percentage (2021)

PandasHardSenior level~10 min

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.

installers
installer_idonboarded_on
102020-12-10
82021-01-13
52021-02-16
72021-03-08
42021-05-17
requests
request_idhousehold_idrequested_on
6752020-12-09
1542021-02-09
10632021-03-04
19392021-04-06
3412021-06-03
bookings
request_idinstaller_idpanel_countjob_minutes
10106338
13107396
7810028
17711968
20112192

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 installers

Solve 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

Related Pandas questions