Skip to content

Use merge for county FIPS lookup#8261

Open
trippusultan wants to merge 1 commit into
PolicyEngine:mainfrom
trippusultan:fix-county-fips-merge
Open

Use merge for county FIPS lookup#8261
trippusultan wants to merge 1 commit into
PolicyEngine:mainfrom
trippusultan:fix-county-fips-merge

Conversation

@trippusultan
Copy link
Copy Markdown

Closes #5804

Summary

Replaces indexed .loc lookups with a left pd.merge() when mapping county_fips to county_name and state in county formula.

Why

Issue #5804 requested moving to pd.merge() for clearer missing-value behavior and explicit join semantics.

Change

  • File: policyengine_us/variables/household/demographic/geographic/county/county.py
  • Replaced:
    • set_index(...).loc[...] lookups
  • With:
    • pd.DataFrame({"county_fips": county_fips})
    • pd.merge(..., on="county_fips", how="left")
    • Read merged county_name and state columns

Notes

  • Join preserves input order and yields NaN for unmatched FIPS rows.
  • No behavior change intended for matched FIPS values.

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.

Modify county FIPS handling in county to use pd.merge() in place of pd.loc()

1 participant