@@ -246,7 +246,7 @@ def semi_annual_report():
246246 })
247247 )
248248 ### GCS ###
249- with pd .ExcelWriter (f"{ GCS_FILE_PATH } FUNCTION_TEST_TIRCP_SAR .xlsx" ) as writer :
249+ with pd .ExcelWriter (f"{ GCS_FILE_PATH } Semi_Annual_Report .xlsx" ) as writer :
250250 summary_table_2 .to_excel (writer , sheet_name = "Summary" , index = True )
251251 df_pivot .to_excel (writer , sheet_name = "FY" , index = True )
252252 return df_pivot
@@ -347,7 +347,7 @@ def pivot(df):
347347 df_2020 = pivot (df_combined .loc [df_combined ['Award_Year' ] == 2020 ])
348348
349349 #GCS
350- with pd .ExcelWriter (f'{ GCS_FILE_PATH } FUNCTION_TEST_PAP .xlsx' ) as writer :
350+ with pd .ExcelWriter (f'{ GCS_FILE_PATH } Program_Allocation_Plan .xlsx' ) as writer :
351351 df_2015 .to_excel (writer , sheet_name = "2015_Cycle_1" , index = True )
352352 df_2016 .to_excel (writer , sheet_name = "2016_Cycle_2" , index = True )
353353 df_2018 .to_excel (writer , sheet_name = "2018_Cycle_3" , index = True )
@@ -363,10 +363,7 @@ def pivot(df):
363363### SHEET CONNECTED TO TABLEAU ###
364364def tableau ():
365365 #Keeping only the columns we want
366- df = project ()
367- #df = df[['Award_Year', 'Project_#','Local_Agency','Project_Title','PPNO', 'County',
368- #'Key_Project_Elements','TIRCP_project_sheet','Allocated_Amount',
369- #'Expended_Amt_project_sheet']]
366+ df = project ()
370367
371368 #Getting percentages & filling in with 0
372369 df ['Expended_Percent' ] = df ['Expended_Amt_project_sheet' ]/ df ['Allocated_Amount' ]
@@ -416,6 +413,39 @@ def progress(df):
416413
417414 df ['Progress' ] = df .apply (progress , axis = 1 )
418415
416+ #Renaming districts
417+ df ['District' ] = (df ['District' ].replace ({7 :'District 7: Los Angeles' ,
418+ 4 :'District 4: Bay Area / Oakland' ,
419+ 'VAR' :'Various' ,
420+ 10 :'District 10: Stockton' ,
421+ 11 :'District 11: San Diego' ,
422+ 3 :'District 3: Marysville / Sacramento' ,
423+ 12 : 'District 12: Orange County' ,
424+ 8 : 'District 8: San Bernardino / Riverside' ,
425+ 5 :'District 5: San Luis Obispo / Santa Barbara' ,
426+ 6 :'District 6: Fresno / Bakersfield' ,
427+ 1 :'District 1: Eureka'
428+ }))
429+ #Renaming counties
430+ df ['County' ] = (df ['County' ].replace ({'LA' : 'Los Angeles' ,
431+ 'VAR' : 'Various' ,
432+ 'MON' : 'Mono' ,
433+ 'ORA' :'Orange' ,
434+ 'SAC' :'Sacramento' ,
435+ 'SD' :'San Diego' ,
436+ 'SF' : 'San Francisco' ,
437+ 'SJ' :'San Joaquin' ,
438+ 'SJ ' : 'San Joaquin' ,
439+ 'FRE' :"Fresno" ,
440+ 'SBD' :'San Bernandino' ,
441+ 'SCL' :'Santa Clara' ,
442+ 'ALA' :'Alameda' ,
443+ 'SM' :'San Mateo' ,
444+ 'SB' : 'San Barbara' ,
445+ 'SON, MRN' : 'Various' ,
446+
447+ }))
448+
419449 #Which projects are large,small, medium
420450 p75 = df .TIRCP_project_sheet .quantile (0.75 ).astype (float )
421451 p25 = df .TIRCP_project_sheet .quantile (0.25 ).astype (float )
@@ -437,7 +467,10 @@ def project_size (row):
437467 'TIRCP_project_sheet' : "TIRCP_Amount" }
438468 ))
439469 ### GCS ###
440- #df.to_csv(f'{GCS_FILE_PATH}df_tableau_sheet.csv', index = False)
470+ with pd .ExcelWriter (f"{ GCS_FILE_PATH } Tableau_Sheet.xlsx" ) as writer :
471+ df .to_excel (writer , sheet_name = "Data" , index = False )
472+ return df
473+
441474 return df
442475
443476'''
@@ -480,14 +513,15 @@ def basic_bar_chart(df, x_col, y_col, colorcol):
480513 )
481514
482515 chart = styleguide .preset_chart_config (chart )
516+ chart .save (f"./Charts/bar_{ x_col } _by_{ y_col } .png" )
483517 return chart
484518
485519
486520# Scatter
487521def basic_scatter_chart (df , x_col , y_col , colorcol ):
488522
489523 chart = (alt .Chart (df )
490- .mark_circle (size = 200 )
524+ .mark_circle (size = 350 )
491525 .encode (
492526 x = alt .X (x_col , title = labeling (x_col )),
493527 y = alt .Y (y_col , title = labeling (y_col )),
@@ -501,5 +535,6 @@ def basic_scatter_chart(df, x_col, y_col, colorcol):
501535 )
502536
503537 chart = styleguide .preset_chart_config (chart )
538+ chart .save (f"./Charts/scatter_{ x_col } _by_{ y_col } .png" )
504539 return chart
505540
0 commit comments