Flag Abnormal Hourly Authorization Volume Against Same-Hour Baselines
Last updated: November 29, 2026
Quick Overview
Using pandas, resample card authorization events into hourly counts and flag hours whose count deviates strongly from the same hour of the week over the prior four weeks.
Capital One
November 29, 20260
0
0 solved
Using pandas, resample card authorization events into hourly counts and flag hours whose count deviates strongly from the same hour of the week over the prior four weeks.
A sudden drop in authorizations can mean a processor outage or a broken merchant integration, and a spike can mean a card testing attack, so Capital One's payments monitoring teams track hourly volume. The reviewer looks for resampling, seasonality-aware baselines, and a baseline that excludes the hour being tested.
What the Interviewer Expects
- Resamples events into a complete hourly series including empty hours
- Builds an hour-of-week key to respect daily and weekly seasonality
- Uses shifted rolling statistics so the current hour is not in its baseline
- Guards against near-zero standard deviation
- Requires minimum history before flagging
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you handle holidays like Black Friday that break weekly seasonality?
- How would you alert on a slow decline rather than a sudden drop?
- How would you reduce alert noise for low-volume hours overnight?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
- Input
auths(auth_ts)with one row per authorization, timestamps in one time zone. - Daily and weekly patterns dominate: 3 a.m. Sunday is not comparable to noon Friday. So the baseline is the same ...
Approach
resample("1h").size()gives a dense hourly series with zeros.- Key =
dayofweek * 24 + hour. - Within each key,
shift(1).rolling(4, min_periods=3)mean and std, so each hour is compared onl...