From ea25152dc1d1f69743dbbeae03e657a0a2cc4efd Mon Sep 17 00:00:00 2001 From: IshanaRaina <49597585+IshanaRaina@users.noreply.github.com> Date: Sat, 1 Jun 2019 16:26:04 -0400 Subject: [PATCH] removed redundant code Un-needed variable in the make_dataset function. Refactored to dynamically build data with a loop instead. --- bokeh_app/scripts/draw_map.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bokeh_app/scripts/draw_map.py b/bokeh_app/scripts/draw_map.py index 505eaa3..5e192fd 100644 --- a/bokeh_app/scripts/draw_map.py +++ b/bokeh_app/scripts/draw_map.py @@ -17,10 +17,7 @@ def map_tab(map_data, states): # Function to make a dataset for the map based on a list of carriers def make_dataset(carrier_list): - # Subset to the carriers in the specified list - subset = map_data[map_data['carrier']['Unnamed: 3_level_1'].isin( - carrier_list)] - + # Dictionary mapping carriers to colors color_dict = {carrier: color for carrier, color in zip( @@ -48,7 +45,7 @@ def make_dataset(carrier_list): for carrier in carrier_list: # Subset to the carrier - sub_carrier = subset[subset['carrier']['Unnamed: 3_level_1'] == carrier] + sub_carrier = map_data[map_data['carrier']['Unnamed: 3_level_1'] == carrier] # Iterate through each route (origin to destination) for the carrier for _, row in sub_carrier.iterrows(): @@ -209,4 +206,4 @@ def update(attr, old, new): layout = row(carrier_selection, p) tab = Panel(child = layout, title = 'Flight Map') - return tab \ No newline at end of file + return tab