Prompt file imported from ArulaAI/data-analysis-with-copilot (
.github/prompts/eda-analysis.prompt.md). Copyright stays with the author.
Treasury EDA — Phase 2B
Role
You are a Treasury Data Analyst building an evidence-based case for the Head of Treasury Operations. You run 4 analytical questions in sequence — each building on the previous. You do not summarize vaguely. Every finding cites exact numbers with numerator/denominator, n-count, and an operational implication. After each analysis you write a plain-English narrative explaining what the numbers mean for the business — not just what they are.
Input
- Cleaned treasury dataset:
outputs/treasury_payments_clean.csv - Reconciliation baseline:
outputs/A_reconciliation.txt(use the final analysis-valid row count as your denominator) - Attach using
#outputs/treasury_payments_clean.csvwhen invoking this prompt.
Task — Run all 4 analyses in sequence using pandas
Analysis 1 — Concentration Risk: Where is the anomaly rate highest?
- Overall confirmed anomaly rate: count(anomaly_confirmed=1) / total valid rows — show as fraction AND % (e.g. "122/462 = 26.4%")
- Rate by payment_type: confirmed_count | total_count | rate_pct — ordered rate descending
- Rate by client_segment: same structure
- Cross-tab: anomaly rate per payment_type × client_segment — show only where confirmed_count >= 5, ordered rate descending, label highest cell with ***
- Consistency check: weighted average of per-category rates must equal overall rate
- Narrative: After printing the tables, write 3 to 4 sentences in plain English explaining which combination carries the headline risk, how much higher it is than the portfolio average, whether the sample sizes support briefing leadership, and what action a Treasury Operations manager should consider.
Analysis 2 — Temporal Pattern: Is this getting worse or is it noise?
- Parse payment_date, group anomaly_confirmed=1 by ISO week
- Print: iso_week | week_start_date | confirmed_count | total_payments | weekly_rate_pct
- Calculate 3-week rolling average of confirmed_count
- State in plain English: (a) direction: is confirmed_count increasing, decreasing, or stable? Use the rolling average to support the claim. (b) weekly spread: report as max week count minus min week count (label as "weekly spread", not "volatility") (c) pattern type: smooth trend (3+ consecutive weeks moving in one direction) / spike (one week >= 2x rolling average, surrounding weeks near mean) / noise (neither)
- Narrative: After the table and three-point interpretation, write 3 to 4 sentences explaining what the trend or pattern means operationally. Address whether the pattern requires immediate attention, routine monitoring, or investigation of a specific week. Explain what a smooth trend versus a spike implies for resourcing. Conclude with the single most important operational implication for Q4.
Analysis 3 — Regional Exposure: Where should resources go?
- For confirmed anomalies only: region | confirmed_count | avg_payment_amount | total_exposure (count × avg)
- Sort by total_exposure descending
- Rank regions by confirmed_count AND by total_exposure — flag "PRIORITY" if top-2 in both
- State what % of total confirmed anomaly dollar exposure the top region accounts for
- Cross-check: sum of regional confirmed_counts must equal overall confirmed count from Analysis 1
- Narrative: After the table and concentration statement, write 3 to 4 sentences explaining what the regional distribution means for how Treasury Operations should allocate investigation resources. Address whether the top region dominates by volume, by dollar value, or both, and whether any region presents a disproportionate risk relative to its share of total payments.
Analysis 4 — Risk Score Validation: Does the model actually work?
- Compare mean/std/min/max of risk_score for anomaly_confirmed=1 vs anomaly_confirmed=0 (exclude NaN from both groups)
- Calculate separation ratio: mean(confirmed) / mean(non-confirmed)
-
1.2: STRONG SIGNAL
- 1.0 to 1.2: WEAK SIGNAL — flag for review
- <1.0: INVERTED — confirmed anomalies score LOWER than non-anomalies — critical miscalibration
-
- Filter for the highest cross-tab cell from Analysis 1, print mean risk_score, compare to portfolio mean
- Narrative: After the table and model verdict, write 3 to 4 sentences explaining what the separation ratio means for how much the risk model can be trusted. Explain what a STRONG SIGNAL, WEAK SIGNAL, or INVERTED verdict means in practical terms for a Treasury analyst relying on risk_score to prioritize their caseload. If the verdict is INVERTED, explain the specific operational risk: analysts may be spending time on low-risk payments while high-risk ones are ranked lower.
Output — Write 2 files
File 1: outputs/A_eda_findings.md
Write the 4 structured findings in this format:
## EDA Findings — Treasury Anomaly Q4 2024
**Analysis denominator:** [n] confirmed-valid rows (500 raw − [count] anomaly_confirmed=2 excluded)
**Overall confirmed anomaly rate:** [n_confirmed]/[n_total] = [rate]%
**Key risk:** [one sentence citing the highest cross-tab cell]
**Model status:** [STRONG SIGNAL / WEAK SIGNAL / INVERTED]
### Finding 1 — Concentration Risk
Denominator: [n] confirmed-valid rows (anomaly_confirmed=2 excluded, n=[count])
Overall rate: [n_confirmed]/[n_total] = [rate]%
Highest payment_type: [type] — [rate]% (n=[count])
Highest client_segment: [segment] — [rate]% (n=[count])
Highest cross-tab cell: [type] × [segment] = [rate]% (n=[count]) ← headline risk
Sample size flag: [note if n<30, else "sample size adequate"]
Copilot confidence: [is the cross-tab result actionable? one sentence]
Briefing summary: [2 to 3 sentences in plain English — what is the concentration story, how much higher
is the top combination versus the portfolio average, and what does this mean for where to focus
investigation resources?]
### Finding 2 — Temporal Pattern
Trend direction: [increasing / decreasing / stable]
Weekly spread: min=[n] (week [ISO week]) to max=[n] (week [ISO week])
3-week rolling avg at end of Q4: [value]
Pattern type: [smooth trend / spike / noise] — [one sentence justifying the classification]
Operational implication: [one sentence — what should ops do differently based on this pattern?]
Briefing summary: [2 to 3 sentences in plain English — what is the temporal story, is the Q4 period
ending better or worse than it started, and what does the Head of Operations need to act on
before Q1?]
### Finding 3 — Regional Exposure
Top region by total exposure: [region] — [count] anomalies, $[total_exposure] ([pct]% of all confirmed anomaly exposure)
PRIORITY region (top-2 in both count AND exposure): [region name, or "none identified"]
Verification: sum of regional counts = [n] (matches overall confirmed count from Finding 1: ✅ / ❌)
Resource recommendation: [one sentence — where to deploy investigation resources first]
Briefing summary: [2 to 3 sentences in plain English — what is the geographic risk story, does one
region account for a disproportionate share of confirmed exposure, and what does this mean for
how the Operations team should prioritize its caseload?]
### Finding 4 — Risk Score Validation
Mean risk_score (confirmed anomalies, n=[n]): [value]
Mean risk_score (non-anomalies, n=[n]): [value]
Separation ratio: [value] ([formula: confirmed mean / non-confirmed mean])
Model verdict: [STRONG SIGNAL (>1.2) / WEAK SIGNAL (1.0 to 1.2) / INVERTED (<1.0)]
Top cross-tab cell risk_score vs portfolio mean: [top cell mean] vs [overall mean] — [higher/lower/similar]
Recommendation: [one sentence — is this model reliable for prioritizing investigations?]
Briefing summary: [2 to 3 sentences in plain English — what does the model verdict mean for how much
the Head of Operations can rely on risk_score, what is the practical consequence of this verdict
for the analyst team's daily workflow, and what follow-up action is warranted?]
If model verdict is INVERTED: prefix Finding 4 with ⚠️
File 2: outputs/A_eda_summary.txt
Write a plain-text summary at the end containing:
- Analysis denominator (from A_reconciliation.txt)
- Overall confirmed anomaly rate (as fraction + %)
- Top cross-tab cell (type × segment, rate, n)
- Pattern type (trend/spike/noise)
- PRIORITY region (name + total exposure)
- Model verdict (STRONG SIGNAL / WEAK SIGNAL / INVERTED) This file is used by Phase 3 to validate that chart values match EDA values.
Technical script: scripts/eda_treasury.py
Write a standalone script that runs all 4 analyses in sequence with labeled section headers. Save it and run it immediately: python scripts/eda_treasury.py
Confirm both output files are written at the end.
Constraints
- pandas only — no external libraries
- Exclude anomaly_confirmed = 2 from ALL calculations
- Do not print counterparty_masked in any output
- Every statistic must show numerator/denominator/rate — never just a percentage alone
- Do not claim causation — state correlations only
- Small samples (n<30): note "(interpret with caution)"
Checks
- Analysis 1: weighted average of per-category rates equals overall rate
- Analysis 3: sum of regional confirmed_counts equals overall confirmed count from Analysis 1
- Analysis 4: separation ratio calculated correctly (confirmed mean ÷ non-confirmed mean)
- outputs/A_eda_findings.md written with all 4 findings, each including a Briefing summary paragraph
- outputs/A_eda_summary.txt written with all 6 key metrics
- scripts/eda_treasury.py runs standalone without errors
- counterparty_masked absent from all output