Skip to content

Address pandas 2.0 deprecation warnings in FBIHateCrimePublications - #2111

Open
niveditasing wants to merge 10 commits into
datacommonsorg:masterfrom
niveditasing:code_fix_fbi
Open

Address pandas 2.0 deprecation warnings in FBIHateCrimePublications#2111
niveditasing wants to merge 10 commits into
datacommonsorg:masterfrom
niveditasing:code_fix_fbi

Conversation

@niveditasing

@niveditasing niveditasing commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary: Replaced deprecated .fillna(method='ffill') with the direct .ffill() method in the preprocessing scripts for Table 13 and Table 14 & added golden files.

Why this change was made

  1. Pandas 2.0+ Compatibility & Deprecation Cleanup
    In modern versions of Pandas (2.0.0 and above), calling .fillna() with the method argument (e.g., method='ffill') is deprecated and raises a FutureWarning (or errors in newer releases). The recommended and idiomatic pandas way to forward-fill missing values is calling .ffill() directly.
  2. Added Goldens files

Test Results: https://storage.mtls.cloud.google.com/datcom-import-test/scripts/fbi/hate_crime/FBIHateCrimePublications/2026_07_28T04_41_11_827936_07_00/input0/validation/validation_output.csv

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the preprocessing scripts for FBI hate crime tables 13 and 14 by replacing the deprecated pandas fillna(method='ffill') calls with the modern .ffill() method. I have no feedback to provide as the changes are correct and align with modern pandas best practices.

@niveditasing niveditasing changed the title testing Address pandas 2.0 deprecation warnings in FBIHateCrimePublications Jul 23, 2026
@niveditasing
niveditasing requested a review from saanikaaa July 28, 2026 11:48
Comment thread scripts/fbi/hate_crime/golden_data/golden_summary_report_t1t10.csv
"validator": "GOLDENS_CHECK",
"params": {
"golden_files": "../../../../golden_data/golden_observations_table14.csv",
"input_files": "../../../../table14/table14_output.csv"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Validation Config — Missing Date Freshness Validation

  • File: scripts/fbi/hate_crime/validation_config.json
  • Finding: validation_config.json sets up DELETED_RECORDS_PERCENT and GOLDENS_CHECK for all tables, but omits date freshness validation.
  • Impact: Golden summary reports intentionally exclude MaxDate so that data refreshes do not fail when new observation dates are ingested. However, if a future refresh silently fails to ingest new publication years or regresses, the golden checks alone will still pass.
  • Recommendation: Add a SQL_VALIDATOR date freshness check to validation_config.json (e.g. verifying that MaxDate is at least 2023 or within allowable lag):
    {
      "rule_id": "check_max_date_freshness",
      "description": "Verifies latest observation year is within 3 years of current date",
      "validator": "SQL_VALIDATOR",
      "params": {
        "query": "SELECT MAX(CAST(SUBSTRING(CAST(MaxDate AS VARCHAR), 1, 4) AS INT)) AS max_year FROM stats",
        "condition": "max_year >= (EXTRACT(YEAR FROM CURRENT_DATE) - 3)"
      }
    }

@rohitkumarbhagat rohitkumarbhagat Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this check would be helpful. pls check again. Other golden checks wont ensure latest date data is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants