Clean Messy Amount and Date Strings From a Merchant Settlement File

Last updated: November 29, 2026

Quick Overview

A merchant settlement file stores amounts as strings like "$1,234.56", "(45.00)" and "12.50 CR", and dates in mixed formats. Write pandas code that parses them into numeric amounts and datetimes and flags rows that failed to parse.

Capital One
Data Manipulation (SQL/Python)
Data Engineer
Capital One
November 29, 2026
Data Engineer
Take-home Project
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


A merchant settlement file stores amounts as strings like "$1,234.56", "(45.00)" and "12.50 CR", and dates in mixed formats. Write pandas code that parses them into numeric amounts and datetimes and flags rows that failed to parse.

Capital One's merchant and commercial payments teams receive partner files with inconsistent formatting, and analysts must clean them without silently corrupting dollar values. The reviewer looks for explicit parsing rules, negative amount conventions used in accounting, and a parse-failure flag instead of dropping rows.

What the Interviewer Expects
  • Handles currency symbols, thousands separators and codes
  • Treats parentheses, leading minus and CR suffix as negatives
  • Maps known null tokens to NaN
  • Rejects malformed numbers instead of guessing
  • Parses mixed date formats with errors coerced and flagged
  • Raises the ambiguity of day-first versus month-first dates
Key Topics to Cover
pandas
regex
data cleaning
date parsing
data quality
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you detect that a partner switched to day-first dates?
  • Would you use float or Decimal for these amounts and why?
  • How would you report parse failures back to the partner?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data
  • Columns: amount_raw, posted_raw (strings, possibly missing).
  • Conventions: (45.00) and 45.00 CR mean credits, so negative. USD 12 means 12.
  • Null tokens: empty, N/A, NA, NULL, -....
Approach

Write a scalar parse_amount that normalizes case, detects sign markers, strips everything except digits and the decimal point, and rejects strings with zero or multiple decimal points. Apply it with...


Submit Your Answer
Markdown supported