# outputs that use both base year and future year values for year in analysis_years: df_year = get_multiyear_data(project_fc, project_type, outdf_base, year) # if it's base year, then append values to bottom of outdf_base, # if it's future year, then left-join the values to the outdf. # table has metrics as rows; years as columns (and will also append if year == min(analysis_years): out_df = outdf_base.rename(columns={0: 'projval_{}'.format(year)}) df_year = df_year.rename(columns={0: 'projval_{}'.format(year)}) out_df = out_df.append(df_year) else: df_year = df_year.rename(columns={0: 'projval_{}'.format(year)}) out_df = out_df.join(df_year) out_df = utils.join_xl_import_template(template_xl, params.xlsx_import_sheet, out_df) # get community type and regional level data df_aggvals = pd.read_csv(params.aggvals_csv, index_col='Unnamed: 0') col_aggvals_year = 'year' region_headname = 'REGION' cols_ctype_reg = [project_ctype, region_headname] aggval_headers = { col: 'CommunityType' for col in df_aggvals.columns if col != region_headname } for year in analysis_years: df_agg_yr = df_aggvals[df_aggvals[col_aggvals_year] == year] # filter to specific year df_agg_yr = df_agg_yr[
'travel_purpose', 'origin_blockgroup_id', 'destination_blockgroup_id', 'trip_primary_mode', 'trip_start_time' ] #fields to use from Replica trip data CSVs df_tshed_data, link_trip_summary = make_trip_shed_report( tripdata_files, trip_data_fields, csvcol_valfield, val_aggn_type, csvcol_bgid, fc_bg_in, fc_tripshed_out, fc_poly_id_field, years, [csvcol_mode, csvcol_purpose], run_full_shed_report) if run_full_shed_report: df_trip_modes = link_trip_summary.loc[link_trip_summary['category'] == csvcol_mode] df_trip_purposes = link_trip_summary.loc[link_trip_summary['category'] == csvcol_purpose] df_tshed_data_out = utils.join_xl_import_template( xlsx_template, ws_tshed_data, df_tshed_data) df_trip_modes_out = utils.join_xl_import_template( xlsx_template, ws_trip_modes, df_trip_modes) df_trip_purposes_out = utils.join_xl_import_template( xlsx_template, ws_trip_purposes, df_trip_purposes) # output_csv = os.path.join(xlsx_out_dir, 'PPA_TripShed_{}_{}.csv'.format( # proj_name, timesufx) # df_tshed_data.to_csv(output_csv) # probably not necessary to output to CSV if outputting to Excel. utils.overwrite_df_to_xlsx(df_tshed_data_out, xlsx_template, xlsx_out, ws_tshed_data, start_row=0, start_col=0)