From 32864c472db4e0e22a35af6534a3b368848e833d Mon Sep 17 00:00:00 2001 From: Ananta Shrestha Date: Fri, 11 Oct 2024 12:25:54 -0700 Subject: [PATCH 1/7] Refactor extract_kwh(footprint_dict) and extract_co2(footprint_dict) into a single parameterized function extract_footprint(footprint_dict, footprint_key). Removed the print missing kwh/co2, footprint_dict since it was polluting the cell execution, and in all these cases footprint_dict was empty. --- viz_scripts/scaffolding.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/viz_scripts/scaffolding.py b/viz_scripts/scaffolding.py index 3e46ebab..362c292f 100644 --- a/viz_scripts/scaffolding.py +++ b/viz_scripts/scaffolding.py @@ -59,6 +59,7 @@ async def add_base_mode_footprint(trip_list): labels = await emcu.read_json_resource("label-options.default.json") value_to_basemode = {mode["value"]: mode.get("base_mode", mode.get("baseMode", "UNKNOWN")) for mode in labels["MODE"]} + counter_trip_error = 0 for trip in trip_list: #format so emffc can get id for metadata trip['data']['_id'] = trip['_id'] @@ -81,7 +82,6 @@ async def add_base_mode_footprint(trip_list): trip['data']['replaced_base_mode'] = "UNKNOWN" trip['data']['mode_confirm_footprint'] = {} trip['data']['replaced_mode_footprint'] = {} - return trip_list async def load_all_confirmed_trips(tq, add_footprint): @@ -501,29 +501,21 @@ def unit_conversions(df): df['distance_miles']= df["distance"]*0.00062 #meters to miles df['distance_kms'] = df["distance"] / 1000 #meters to kms -def extract_kwh(footprint_dict): - if 'kwh' in footprint_dict.keys(): - return footprint_dict['kwh'] +def extract_footprint(footprint_dict, footprint_key): + if footprint_key in footprint_dict.keys(): + return footprint_dict[footprint_key] else: - print("missing kwh", footprint_dict) - return np.nan - -def extract_co2(footprint_dict): - if 'kg_co2' in footprint_dict.keys(): - return footprint_dict['kg_co2'] - else: - print("missing co2", footprint_dict) return np.nan def unpack_energy_emissions(expanded_ct): - expanded_ct['Mode_confirm_kg_CO2'] = expanded_ct['mode_confirm_footprint'].apply(extract_co2) + expanded_ct['Mode_confirm_kg_CO2'] = expanded_ct['mode_confirm_footprint'].apply(extract_footprint, footprint_key='kg_co2') expanded_ct['Mode_confirm_lb_CO2'] = kg_to_lb(expanded_ct['Mode_confirm_kg_CO2']) - expanded_ct['Replaced_mode_kg_CO2'] = expanded_ct['replaced_mode_footprint'].apply(extract_co2) + expanded_ct['Replaced_mode_kg_CO2'] = expanded_ct['replaced_mode_footprint'].apply(extract_footprint, footprint_key='kg_co2') expanded_ct['Replaced_mode_lb_CO2'] = kg_to_lb(expanded_ct['Replaced_mode_kg_CO2']) CO2_impact(expanded_ct) - expanded_ct['Replaced_mode_EI(kWH)'] = expanded_ct['replaced_mode_footprint'].apply(extract_kwh) - expanded_ct['Mode_confirm_EI(kWH)'] = expanded_ct['mode_confirm_footprint'].apply(extract_kwh) + expanded_ct['Replaced_mode_EI(kWH)'] = expanded_ct['replaced_mode_footprint'].apply(extract_footprint, footprint_key='kwh') + expanded_ct['Mode_confirm_EI(kWH)'] = expanded_ct['mode_confirm_footprint'].apply(extract_footprint, footprint_key='kwh') energy_impact(expanded_ct) return expanded_ct From 7e1aafaa9b74ba54d4225ee50634ecc4ceb6e535 Mon Sep 17 00:00:00 2001 From: Ananta Shrestha Date: Fri, 11 Oct 2024 12:28:24 -0700 Subject: [PATCH 2/7] Update exception handling for add_base_mode_footprint(). Now we log the actual exception error reason, also while accounting the total number of trips where there were errors. --- viz_scripts/scaffolding.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/viz_scripts/scaffolding.py b/viz_scripts/scaffolding.py index 362c292f..e368916d 100644 --- a/viz_scripts/scaffolding.py +++ b/viz_scripts/scaffolding.py @@ -5,6 +5,7 @@ from collections import defaultdict from collections import OrderedDict import difflib +import logging import emission.storage.timeseries.abstract_timeseries as esta import emission.storage.timeseries.tcquery as esttc @@ -76,12 +77,14 @@ async def add_base_mode_footprint(trip_list): trip['data']['replaced_base_mode'] = "UNKNOWN" trip['data']['replaced_mode_footprint'] = {} - except: - print("hit exception") + except Exception as e: + counter_trip_error = counter_trip_error + 1 + logging.debug(f"The exception is : {e} for the trip - {trip['data']['_id']}") trip['data']['base_mode'] = "UNKNOWN" trip['data']['replaced_base_mode'] = "UNKNOWN" trip['data']['mode_confirm_footprint'] = {} trip['data']['replaced_mode_footprint'] = {} + logging.debug(f"There are {counter_trip_error} trip errors") return trip_list async def load_all_confirmed_trips(tq, add_footprint): From ea1bf886b069855c6841017ec2683212fc91f86d Mon Sep 17 00:00:00 2001 From: Ananta Shrestha Date: Fri, 11 Oct 2024 12:40:06 -0700 Subject: [PATCH 3/7] Replace the label text from Labeled and Inferred by OpenPATH to Inferred from prior labels --- viz_scripts/generic_metrics.ipynb | 12 ++++++------ viz_scripts/mode_specific_metrics.ipynb | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/viz_scripts/generic_metrics.ipynb b/viz_scripts/generic_metrics.ipynb index b0992f16..f3180029 100644 --- a/viz_scripts/generic_metrics.ipynb +++ b/viz_scripts/generic_metrics.ipynb @@ -244,7 +244,7 @@ " plot_and_text_stacked_bar_chart(expanded_ct, lambda df: (df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False)), \n", " \"Labeled by user\\n\"+stacked_bar_quality_text_labeled, ax[0], text_results[0], colors_mode, debug_df, values_to_translations)\n", " plot_and_text_stacked_bar_chart(expanded_ct_inferred, lambda df: (df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False)), \n", - " \"Labeled and Inferred by OpenPATH\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", + " \"Inferred from prior labels\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", " plot_and_text_stacked_bar_chart(expanded_ct_sensed, lambda df: (df.groupby(\"primary_mode\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False)), \n", " \"Sensed by OpenPATH\\n\"+stacked_bar_quality_text_sensed, ax[2], text_results[2], colors_sensed, debug_df_sensed)\n", " set_title_and_save(fig, text_results, plot_title_no_quality, file_name)\n", @@ -297,7 +297,7 @@ " plot_and_text_stacked_bar_chart(expanded_ct_commute, lambda df: df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", " \"Labeled by user\\n\"+stacked_bar_quality_text_commute_labeled, ax[0], text_results[0], colors_mode, debug_df, values_to_translations)\n", " plot_and_text_stacked_bar_chart(expanded_ct_inferred_commute, lambda df: df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", - " \"Labeled and Inferred by OpenPATH\\n\"+stacked_bar_quality_text_commute_inferred, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", + " \"Inferred from prior labels\\n\"+stacked_bar_quality_text_commute_inferred, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", " set_title_and_save(fig, text_results, plot_title, file_name)\n", "except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n", " plt.clf()\n", @@ -332,7 +332,7 @@ " plot_and_text_stacked_bar_chart(expanded_ct, lambda df: df.groupby(\"purpose_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", " \"Labeled by user\\n\"+stacked_bar_quality_text_labeled, ax[0], text_results[0], colors_purpose, debug_df, value_to_translations_purpose)\n", " plot_and_text_stacked_bar_chart(expanded_ct_inferred, lambda df: df.groupby(\"purpose_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", - " \"Labeled and Inferred by OpenPATH\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_purpose, debug_df_inferred)\n", + " \"Inferred from prior labels\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_purpose, debug_df_inferred)\n", " set_title_and_save(fig, text_results, plot_title_no_quality, file_name)\n", "except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n", " plt.clf()\n", @@ -389,7 +389,7 @@ " plot_and_text_stacked_bar_chart(expanded_ct_u80, lambda df: df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", " \"Labeled by user\\n\"+labeled_u80_quality_text, ax[0], text_results[0], colors_mode, debug_df, values_to_translations)\n", " plot_and_text_stacked_bar_chart(expanded_ct_inferred, lambda df: df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", - " \"Labeled and Inferred by OpenPATH\\n\"+inferred_u80_quality_text, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", + " \"Inferred from prior labels\\n\"+inferred_u80_quality_text, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", " plot_and_text_stacked_bar_chart(expanded_ct_sensed_u80, lambda df: df.groupby(\"primary_mode\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", " \"Sensed by OpenPATH\\n\"+sensed_u80_quality_text, ax[2], text_results[2], colors_sensed, debug_df_sensed)\n", " set_title_and_save(fig, text_results, plot_title_no_quality, file_name)\n", @@ -431,7 +431,7 @@ " plot_and_text_stacked_bar_chart(expanded_ct, lambda df: df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n", " \"Labeled by user\\n\"+stacked_bar_quality_text_labeled, ax[0], text_results[0], colors_mode, debug_df, values_to_translations)\n", " plot_and_text_stacked_bar_chart(expanded_ct_inferred, lambda df: df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n", - " \"Labeled and Inferred by OpenPATH\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", + " \"Inferred from prior labels\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", " plot_and_text_stacked_bar_chart(expanded_ct_sensed, lambda df: df.groupby(\"primary_mode\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n", " \"Sensed by OpenPATH\\n\"+stacked_bar_quality_text_sensed, ax[2], text_results[2], colors_sensed, debug_df_sensed)\n", " set_title_and_save(fig, text_results, plot_title_no_quality, file_name) \n", @@ -478,7 +478,7 @@ " plot_and_text_stacked_bar_chart(labeled_land_trips_df, lambda df: df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n", " \"Labeled by user\\n\"+labeled_land_quality_text, ax[0], text_results[0], colors_mode, debug_df, values_to_translations)\n", " plot_and_text_stacked_bar_chart(inferred_land_trips_df, lambda df: df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n", - " \"Labeled and Inferred by OpenPATH\\n\"+inferred_land_quality_text, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", + " \"Inferred from prior labels\\n\"+inferred_land_quality_text, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", " plot_and_text_stacked_bar_chart(sensed_land_trips_df, lambda df: df.groupby(\"primary_mode\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n", " \"Sensed by OpenPATH\\n\"+sensed_land_quality_text, ax[2], text_results[2], colors_sensed, debug_df_sensed)\n", " set_title_and_save(fig, text_results, plot_title_no_quality, file_name) \n", diff --git a/viz_scripts/mode_specific_metrics.ipynb b/viz_scripts/mode_specific_metrics.ipynb index a1656301..6e50b2a6 100644 --- a/viz_scripts/mode_specific_metrics.ipynb +++ b/viz_scripts/mode_specific_metrics.ipynb @@ -264,7 +264,7 @@ " plot_and_text_stacked_bar_chart(data_eb, lambda df: df.groupby(\"purpose_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False),\n", " f\"Labeled `{mode_of_interest}` by user\\n\"+stacked_bar_quality_text, ax[0], text_results[0], colors_purpose, debug_df, value_to_translations_purpose)\n", " plot_and_text_stacked_bar_chart(data_eb_inferred, lambda df: df.groupby(\"purpose_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False),\n", - " f\"Labeled and Inferred `{mode_of_interest}` by OpenPATH\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_purpose, debug_df_inferred, value_to_translations_purpose)\n", + " f\"Inferred `{mode_of_interest}` from prior labels\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_purpose, debug_df_inferred, value_to_translations_purpose)\n", " plot_title = plot_title_no_quality + \"\\n\" + f\"For {mode_of_interest}: \" + quality_text\n", " set_title_and_save(fig, text_results, plot_title, file_name)\n", "except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n", @@ -301,7 +301,7 @@ " plot_and_text_stacked_bar_chart(data_eb, lambda df: df.groupby(\"replaced_mode_w_other\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n", " \"Labeled by user\\n (Trip distance)\\n\"+stacked_bar_quality_text, ax[0], text_results[0], colors_replaced, debug_df, value_to_translations_replaced)\n", " plot_and_text_stacked_bar_chart(data_eb_inferred, lambda df: df.groupby(\"replaced_mode_w_other\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n", - " \"Labeled and Inferred by OpenPATH\\n (Trip distance)\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_replaced, debug_df_inferred, value_to_translations_replaced)\n", + " \"Inferred from prior labels\\n (Trip distance)\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_replaced, debug_df_inferred, value_to_translations_replaced)\n", " plot_title = plot_title_no_quality\n", " set_title_and_save(fig, text_results, plot_title, file_name)\n", "except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n", @@ -338,7 +338,7 @@ " plot_and_text_stacked_bar_chart(data_eb, lambda df: df.groupby(\"replaced_mode_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", " f\"Labeled `{mode_of_interest}` by user\\n\"+stacked_bar_quality_text, ax[0], text_results[0], colors_replaced, debug_df, value_to_translations_replaced)\n", " plot_and_text_stacked_bar_chart(data_eb_inferred, lambda df: df.groupby(\"replaced_mode_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n", - " f\"Labeled and Inferred `{mode_of_interest}` by OpenPATH\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_replaced, debug_df_inferred, value_to_translations_replaced)\n", + " f\"Inferred `{mode_of_interest}` from prior labels\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_replaced, debug_df_inferred, value_to_translations_replaced)\n", " plot_title = plot_title_no_quality + \"\\n\" + f\"For {mode_of_interest}: \" + quality_text\n", " set_title_and_save(fig, text_results, plot_title, file_name)\n", "except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n", From bc1850bd194d8392fc7821cfa70ef41de3046bd8 Mon Sep 17 00:00:00 2001 From: Ananta Shrestha Date: Fri, 11 Oct 2024 12:47:27 -0700 Subject: [PATCH 4/7] Fix the typo from relecant to relevant --- viz_scripts/generic_metrics.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viz_scripts/generic_metrics.ipynb b/viz_scripts/generic_metrics.ipynb index f3180029..b4f92c27 100644 --- a/viz_scripts/generic_metrics.ipynb +++ b/viz_scripts/generic_metrics.ipynb @@ -68,7 +68,7 @@ "if survey_info.get('trip-labels', None) == 'ENKETO':\n", " ipython = get_ipython()\n", " ipython._showtraceback = scaffolding.no_traceback_handler\n", - " raise Exception(\"The plots in this notebook are not relecant for ENKETO trip-labels\")" + " raise Exception(\"The plots in this notebook are not relevant for ENKETO trip-labels\")" ] }, { From e6d14339317dddc65d456a5d47f200eea34ad654 Mon Sep 17 00:00:00 2001 From: Ananta Shrestha Date: Tue, 15 Oct 2024 11:37:08 -0700 Subject: [PATCH 5/7] Pass add_footprint as additional function parameter for load_viz_notebook_inferred_data(,..,add_footprint). Use base_mode AIR to filter out the trip without air mode, instead of internal label --- viz_scripts/generic_metrics.ipynb | 10 ++++++---- viz_scripts/scaffolding.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/viz_scripts/generic_metrics.ipynb b/viz_scripts/generic_metrics.ipynb index c837dde8..3c2dfe80 100644 --- a/viz_scripts/generic_metrics.ipynb +++ b/viz_scripts/generic_metrics.ipynb @@ -121,7 +121,8 @@ " program,\n", " study_type,\n", " dynamic_labels,\n", - " include_test_users=include_test_users)" + " include_test_users=include_test_users,\n", + " add_footprint=True)" ] }, { @@ -166,7 +167,8 @@ " program,\n", " study_type,\n", " dynamic_labels,\n", - " include_test_users=include_test_users)" + " include_test_users=include_test_users,\n", + " add_footprint=True)" ] }, { @@ -466,8 +468,8 @@ "try:\n", " ## We do an existence check for the labeled df because we want to display the sensed value even if we don't have the labeled value\n", " ## but we don't need to have an existence check for sensed because in that case we will have no data to display\n", - " labeled_land_trips_df = expanded_ct[expanded_ct['mode_confirm_w_other'] != \"air\"] if \"mode_confirm_w_other\" in expanded_ct.columns else None\n", - " inferred_land_trips_df = expanded_ct_inferred[expanded_ct_inferred['mode_confirm_w_other'] != \"air\"] if \"mode_confirm_w_other\" in expanded_ct_inferred.columns else None\n", + " labeled_land_trips_df = expanded_ct[expanded_ct['base_mode'] != \"AIR\"] if \"mode_confirm_w_other\" in expanded_ct.columns else None\n", + " inferred_land_trips_df = expanded_ct_inferred[expanded_ct_inferred['base_mode'] != \"AIR\"] if \"mode_confirm_w_other\" in expanded_ct_inferred.columns else None\n", " sensed_land_trips_df = expanded_ct_sensed[expanded_ct_sensed['primary_mode'] != \"AIR_OR_HSR\"]\n", " \n", " sensed_land_quality_text = f\"{len(sensed_land_trips_df)} trips ({round(len(sensed_land_trips_df)/len(expanded_ct_sensed)*100)}% of all trips)\\nfrom {scaffolding.unique_users(sensed_land_trips_df)} {sensed_match.group(3)}\"\n", diff --git a/viz_scripts/scaffolding.py b/viz_scripts/scaffolding.py index e368916d..e11d7af9 100644 --- a/viz_scripts/scaffolding.py +++ b/viz_scripts/scaffolding.py @@ -257,7 +257,7 @@ async def map_trip_data(expanded_trip_df, study_type, dynamic_labels): return expanded_trip_df -async def load_viz_notebook_inferred_data(year, month, program, study_type, dynamic_labels, include_test_users=False): +async def load_viz_notebook_inferred_data(year, month, program, study_type, dynamic_labels, include_test_users=False, add_footprint=False): """ Inputs: year/month/program/study_type = parameters from the visualization notebook dic_* = label mappings; if dic_pur is included it will be used to recode trip purpose @@ -266,7 +266,7 @@ async def load_viz_notebook_inferred_data(year, month, program, study_type, dyna """ # Access database tq = get_time_query(year, month) - participant_ct_df = await load_all_participant_trips(program, tq, include_test_users) + participant_ct_df = await load_all_participant_trips(program, tq, include_test_users, add_footprint) inferred_ct = filter_inferred_trips(participant_ct_df) expanded_it = expand_inferredlabels(inferred_ct) expanded_it = await map_trip_data(expanded_it, study_type, dynamic_labels) From 835407e6748f1037a707e63f093142a2ad99e5f4 Mon Sep 17 00:00:00 2001 From: Ananta Narayan Shrestha Date: Fri, 18 Oct 2024 16:02:54 -0700 Subject: [PATCH 6/7] Update viz_scripts/scaffolding.py Co-authored-by: Jack Greenlee --- viz_scripts/scaffolding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viz_scripts/scaffolding.py b/viz_scripts/scaffolding.py index e11d7af9..d79e8c82 100644 --- a/viz_scripts/scaffolding.py +++ b/viz_scripts/scaffolding.py @@ -79,7 +79,7 @@ async def add_base_mode_footprint(trip_list): except Exception as e: counter_trip_error = counter_trip_error + 1 - logging.debug(f"The exception is : {e} for the trip - {trip['data']['_id']}") + logging.exception(f"Exception in add_base_mode_footprint for trip - {trip['data']['_id']}") trip['data']['base_mode'] = "UNKNOWN" trip['data']['replaced_base_mode'] = "UNKNOWN" trip['data']['mode_confirm_footprint'] = {} From 4662360836d8e79bf40d7526ab1dde10d99616d8 Mon Sep 17 00:00:00 2001 From: Ananta Narayan Shrestha Date: Fri, 18 Oct 2024 16:05:21 -0700 Subject: [PATCH 7/7] Update check for base_mode column in expanded_ct/_inferred columns Co-authored-by: Jack Greenlee --- viz_scripts/generic_metrics.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/viz_scripts/generic_metrics.ipynb b/viz_scripts/generic_metrics.ipynb index 3c2dfe80..9a50314c 100644 --- a/viz_scripts/generic_metrics.ipynb +++ b/viz_scripts/generic_metrics.ipynb @@ -468,8 +468,8 @@ "try:\n", " ## We do an existence check for the labeled df because we want to display the sensed value even if we don't have the labeled value\n", " ## but we don't need to have an existence check for sensed because in that case we will have no data to display\n", - " labeled_land_trips_df = expanded_ct[expanded_ct['base_mode'] != \"AIR\"] if \"mode_confirm_w_other\" in expanded_ct.columns else None\n", - " inferred_land_trips_df = expanded_ct_inferred[expanded_ct_inferred['base_mode'] != \"AIR\"] if \"mode_confirm_w_other\" in expanded_ct_inferred.columns else None\n", + " labeled_land_trips_df = expanded_ct[expanded_ct['base_mode'] != \"AIR\"] if \"base_mode\" in expanded_ct.columns else None\n", + " inferred_land_trips_df = expanded_ct_inferred[expanded_ct_inferred['base_mode'] != \"AIR\"] if \"base_mode\" in expanded_ct_inferred.columns else None\n", " sensed_land_trips_df = expanded_ct_sensed[expanded_ct_sensed['primary_mode'] != \"AIR_OR_HSR\"]\n", " \n", " sensed_land_quality_text = f\"{len(sensed_land_trips_df)} trips ({round(len(sensed_land_trips_df)/len(expanded_ct_sensed)*100)}% of all trips)\\nfrom {scaffolding.unique_users(sensed_land_trips_df)} {sensed_match.group(3)}\"\n",