Skip to content

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

@anth-volk

Description

@anth-volk

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"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions