Skip to content

Commit

Permalink
added funding type code
Browse files Browse the repository at this point in the history
  • Loading branch information
amandaha8 committed Jan 31, 2025
1 parent 4183c25 commit c18b87a
Show file tree
Hide file tree
Showing 4 changed files with 639 additions and 3,797 deletions.
20 changes: 15 additions & 5 deletions dla/iija/_data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,24 @@ def add_new_codes(df):

## adding updated program codes 1/30/25
new_codes = update_program_code_list_2025()
code_map = dict(new_codes[['iija_program_code', 'program_name']].values)

df['program_code_description'] = df.program_code.map(code_map)
iija_code_map = dict(new_codes[['iija_program_code', 'program_name']].values)
df['program_code_description'] = df.program_code.map(iija_code_map)

# Add funding_type_code
funding_type_code_df = new_codes[[
'iija_program_code',
'funding_type_code']].drop_duplicates()

df = pd.merge(df, funding_type_code_df,
left_on = "program_code",
right_on = "iija_program_code",
how = "left")
# Turn summary_recipient_defined_text_field_1_value to a string
df['summary_recipient_defined_text_field_1_value'] = df['summary_recipient_defined_text_field_1_value'].astype(str)

# Amanda: January 2025, notified this should be called emergency supplement funding
#df.loc[df.program_code =='ER01', 'program_code_description'] = 'Emergency Relieve Funding'
#df.loc[df.program_code =='ER03', 'program_code_description'] = 'Emergency Relieve Funding'
df.loc[df.program_code =='ER01', 'program_code_description'] = 'Emergency Supplement Funding'
df.loc[df.program_code =='ER03', 'program_code_description'] = 'Emergency Supplement Funding'

return df

Expand Down
8 changes: 5 additions & 3 deletions dla/iija/_script_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ def condense_df(df):
# make sure columns are in string format
df[['county_code', 'improvement_type',
'implementing_agency_locode', 'district',
'program_code_description', 'recipient_project_number']] = df[['county_code', 'improvement_type',
'program_code_description', 'recipient_project_number',
"funding_type_code"]] = df[['county_code', 'improvement_type',
'implementing_agency_locode', 'district',
'program_code_description', 'recipient_project_number']].astype(str)
'program_code_description', 'recipient_project_number',
"funding_type_code"]].astype(str)
# copy county column over to use for project title name easier
df['county_name_title'] = df['county_name']
# copy program code column over to use for project description column easier
Expand All @@ -272,7 +274,7 @@ def condense_df(df):
.groupby(['fmis_transaction_date','project_number', 'implementing_agency', 'summary_recipient_defined_text_field_1_value'
# , 'program_code', 'program_code_description'
])
.agg({
.agg({'funding_type_code':lambda x:'|'.join(x.unique()),
'program_code':lambda x:'|'.join(x.unique()), # get unique values to concatenate ##hashing this out to group by instead
'program_code_description':lambda x:'|'.join(x.unique()), # get unique values to concatenate ##hashing this out to group by instead
'recipient_project_number':lambda x:'|'.join(x.unique()), #'first',
Expand Down
Loading

0 comments on commit c18b87a

Please sign in to comment.