AnalystPath

Solar Installer Monthly Activity (2021)

PandasHardSenior level~10 min

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.

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, 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 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