General analytics
AuraScore 83/100

Municipal Grant Distribution Anomaly Detection Script Generator

Generates a complete Python audit script to flag geographic and allocation discrepancies in public grant disbursement data.

Use this template when municipal analysts need to verify whether local grant allocations align with statutory equity benchmarks and identify funding anomalies. It provides an automated, reproducible data auditing script with standardized reporting.

Template

Role: Senior Public Sector Analytics Engineer specializing in municipal finance and compliance auditing.

Context

  • Grant Initiative: {{grant_program_name}}
  • Jurisdiction: {{municipality_name}}
  • Statutory Disadvantaged Community Share Target: {{target_disadvantaged_communities_ratio}}
  • Fiscal Evaluation Period: {{fiscal_year}}
  • Input Data Schema: {{raw_disbursement_dataset}}
  • Anomaly Deviation Margin: {{audit_threshold_variance}}

Task

Author a modular Python analytics script utilizing pandas and scipy to ingest municipal disbursement records, calculate geographic allocation distributions, test for statistically significant funding discrepancies, and output clean tabular summaries alongside flagged audit exceptions.

Method

  1. Ingest the structured tabular records defined in {{raw_disbursement_dataset}} and parse grant amounts, timestamp stamps, and census-tract or ward identifiers.
  2. Standardize column data types, imputing missing categorical identifiers with an explicit audit-flag value.
  3. Aggregate total awarded funding by tract designation and calculate the realized proportion allocated to prioritized zones relative to {{target_disadvantaged_communities_ratio}}.
  4. Compute allocation z-scores and variance metrics across regional tranches to detect distribution skew beyond {{audit_threshold_variance}}.
  5. Implement a robust filtering rule that isolates individual disbursements displaying outlier amounts or misaligned category classifications.
  6. Generate summary tables calculating aggregate spend, target variance percentage, and total variance counts.
  7. Format diagnostic logging and export cleaned audit outputs to both standard output and a structured CSV payload.

Constraints

  • MUST write clean, PEP-8 compliant Python 3 code with complete type hints and docstrings for all functions.
  • MUST NOT include mock network requests or placeholder credentials in the executable logic.
  • MUST handle zero-division errors when baseline tract populations or allocations are zero.
  • Execution dependencies must be strictly restricted to pandas, numpy, and scipy.
  • Output code must be self-contained and ready for immediate execution.

Output format

Provide the deliverable in three discrete sections:

  1. Execution Prerequisites: Environment requirements and list of input file columns.
  2. Complete Python Script: The fully functional Python script block.
  3. Output Data Dictionary: A table detailing all generated audit output columns and anomaly trigger criteria.

Self-review

  • Check that every variable from {{grant_program_name}} to {{audit_threshold_variance}} is actively utilized in logic or parameters.
  • Verify that statistical anomaly calculations correctly handle small-sample edge cases.
  • Confirm that no unhandled exceptions can arise from missing or null categorical values.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

data-analytics
data-general
public-sector-nonprofit
python
grants
public sector