Analyze Loan Payments Using Pandas for Key Insights
AffirmData Scientist · Technical ScreenLast updated
This question evaluates data manipulation and aggregation skills using pandas, focusing on computing per-loan payment totals, payment success rates, and a repayment-status flag. It is commonly asked to assess applied data wrangling and numeric summarization abilities in the Data Manipulation (SQL/Python) domain, testing practical application rather than purely conceptual understanding.
loan_payments
+------------+------------+-------------+-----------+---------+ | loan_id | payment_id | payment_date | amount | status | +------------+------------+-------------+-----------+---------+ | L1 | P1 | 2023-01-15 | 250.00 | success | | L1 | P2 | 2023-02-15 | 250.00 | success | | L1 | P3 | 2023-03-15 | 250.00 | success | | L1 | P4 | 2023-04-15 | 250.00 | success | | L2 | P5 | 2023-01-20 | 500.00 | failed | +------------+------------+-------------+-----------+---------+
Scenario
Credit Risk – Analyze loan-payment data with pandas
Question
Using pandas, load the loan_payments table below and compute: (a) total amount paid per loan_id, (b) payment success rate per loan_id, and (c) a flag indicating whether the loan has been fully repaid ($1,000 principal). Return the resulting DataFrame.
Hints
Use groupby, agg, and boolean logic.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.