Skip to content

Commit

Permalink
Add fallback for TAs with no counties_served
Browse files Browse the repository at this point in the history
  • Loading branch information
allejo committed Jan 15, 2024
1 parent f3500df commit 4acc655
Show file tree
Hide file tree
Showing 2 changed files with 476 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/provider-map-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,27 @@ jobs:
import json
import pandas as pd
df = pd.read_csv('src/metadata/providers/providers.csv')
providers_file = 'src/metadata/providers/providers.csv'
# Drop the null values for TAs that don't have counties served
df = df[df['counties_served'].notnull()]
df = pd.read_csv(providers_file')
city_lookup = pd.read_csv('src/metadata/cities_to_county.csv')
city_to_county = dict(zip(city_lookup['City'], city_lookup['County']))
lookup_records = df[df['counties_served'].isna()]['ntd_id']
# Fill in the null values for counties served with the HQ county
for record in lookup_records:
city = df[df['ntd_id'] == record]['hq_city'].values[0]
try:
county = city_to_county[city] or city_to_county[f'City of {city}']
df.loc[df['ntd_id'] == record, 'hq_county'] = county
df.loc[df['ntd_id'] == record, 'counties_served'] = county
except KeyError:
print("No county found for city: ", city)
df.to_csv(providers_file)
# Do a group by for the counties served
county_counts = df['counties_served'].str.split(';') \
Expand Down
Loading

0 comments on commit 4acc655

Please sign in to comment.