policyengine-us
policyengine-us copied to clipboard
Modify county FIPS handling in `county` to use `pd.merge()` in place of `pd.loc()`
Per commentary from Pavel:
We can use pd.merge() with how=left by creating two dataframes and joining them at the index - the benefit is more explicit handling of missing values (fills missing matched with Nan) - something like this:
input_df = pd.DataFrame({"county_fips": county_fips})
result_df = pd.merge(
input_df,
load_county_fips_dataset(),
on="county_fips",
how="left"
)
county_name = result_df["county_name"]
state_code = result_df["state"]