Skip to content

Address pandas 2.0 deprecation warnings in FBIHateCrimePublications#2111

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

Address pandas 2.0 deprecation warnings in FBIHateCrimePublications#2111
niveditasing wants to merge 2 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. Functional Correctness (Propagating Grouped Row Headers)
    The FBI publication Excel files for Tables 13 and 14 use merged/visually-grouped rows where the State and Agency Type are only defined
    on the first row of each section. Subsequent rows for specific cities/agencies are read as NaN by pandas.

 Using .ffill() propagates these parent attributes downwards across the missing rows, ensuring every agency record is correctly resolved

and mapped to its parent State and Agency Type.

@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
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.

2 participants