I am completing an assignment where I have to complete a python code. I need help troubleshooting my syntax because I cannot get it to run. # Import required librariesimport pandas as pdimport dashimport dash_html_components as htmlimport dash_core_components as dccfrom dash.dependencies import Input, Output, Statefrom jupyter_dash import JupyterDashimport plotly.graph_objects as goimport plotly.express as pxfrom dash import no_update# Create a dash applicationapp = JupyterDash(__name__)JupyterDash.infer_jupyter_proxy_config()# REVIEW1: Clear the layout and do not display exception till callback gets executedapp.config.suppress_callback_exceptions = True# Read the airline data into pandas dataframeairline_data = pd.read_csv(‘https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DV0101EN-SkillsNetwork/Data%20Files/airline_data.csv’, encoding = “ISO-8859-1”, dtype={‘Div1Airport’: str, ‘Div1TailNum’: str, ‘Div2Airport’: str, ‘Div2TailNum’: str})# List of years year_list = [i for i in range(2005, 2021, 1)]”””Compute graph data for creating yearly airline performance report Function that takes airline data as input and create 5 dataframes based on the grouping condition to be used for plottling charts and grphs.Argument: df: Filtered dataframeReturns: Dataframes to create graph. “””def compute_data_choice_1(df): # Cancellation Category Count bar_data = df.groupby([‘Month’,’CancellationCode’])[‘Flights’].sum().reset_index() # Average flight time by reporting airline line_data = df.groupby([‘Month’,’Reporting_Airline’])[‘AirTime’].mean().reset_index() # Diverted Airport Landings div_data = df[df[‘DivAirportLandings’] != 0.0] # Source state count map_data = df.groupby([‘OriginState’])[‘Flights’].sum().reset_index() # Destination state count tree_data = df.groupby([‘DestState’, ‘Reporting_Airline’])[‘Flights’].sum().reset_index() return bar_data, line_data, div_data, map_data, tree_data”””Compute graph data for creating yearly airline delay reportThis function takes in airline data and selected year as an input and performs computation for creating charts and plots.Arguments: df: Input airline data.Returns: Computed average dataframes for carrier delay, weather delay, NAS delay, security delay, and late aircraft delay.”””def compute_data_choice_2(df): # Compute delay averages avg_car = df.groupby([‘Month’,’Reporting_Airline’])[‘CarrierDelay’].mean().reset_index() avg_weather = df.groupby([‘Month’,’Reporting_Airline’])[‘WeatherDelay’].mean().reset_index() avg_NAS = df.groupby([‘Month’,’Reporting_Airline’])[‘NASDelay’].mean().reset_index() avg_sec = df.groupby([‘Month’,’Reporting_Airline’])[‘SecurityDelay’].mean().reset_index() avg_late = df.groupby([‘Month’,’Reporting_Airline’])[‘LateAircraftDelay’].mean().reset_index() return avg_car, avg_weather, avg_NAS, avg_sec, avg_late# Application layoutapp.layout = html.Div(children=[ # TODO1: Add title to the dashboardn”, html.H1(‘US Domestic Airline Flights Performance’,n”, style={‘text-align-last’:’centre’,’color’:’#503D36′,’font-size’:24}n”,),n”, # REVIEW2: Dropdown creationn”, # Create an outer division n”, html.Div([ # Add an division html.Div([ # Create an division for adding dropdown helper text for report type html.Div( [ html.H2(‘Report Type:’, style={‘margin-right’: ‘2em’}), ] ), # TODO2: Add a dropdown dcc.Dropdown(id=’input-type’,n”, options=[n”, {‘label’: ‘Yearly Airline Performance Report’, ‘value’: ‘OPT1’},n”, {‘label’: ‘Yearly Airline Delay Report’, ‘value’: ‘OPT2′}n”, ],n”, placeholder=’Select a report type’,n”, style={‘width’:’80%’, ‘padding’:’3px’, ‘font-size’:’20px’, ‘text-align-last’:’center’}n”, )n”, # Place them next to each other using the division style ], style={‘display’:’flex’}), # Add next division html.Div([ # Create an division for adding dropdown helper text for choosing year html.Div( [ html.H2(‘Choose Year:’, style={‘margin-right’: ‘2em’}) ] ), dcc.Dropdown(id=’input-year’, # Update dropdown values using list comphrehension options=[{‘label’: i, ‘value’: i} for i in year_list], placeholder=”Select a year”, style={‘width’:’80%’, ‘padding’:’3px’, ‘font-size’: ’20px’, ‘text-align-last’ : ‘center’}), # Place them next to each other using the division style ], style={‘display’: ‘flex’}), ]), # Add Computed graphs # REVIEW3: Observe how we add an empty division and providing an id that will be updated during callback html.Div([ ], id=’plot1′), html.Div([ html.Div([ ], id=’plot2′), html.Div([ ], id=’plot3′) ], style={‘display’: ‘flex’}),n”, n”, # TODO3: Add a division with two empty divisions inside. See above disvision for example. html.Div([n”, html.Div([ ], id=’plot4′),n”, html.Div([ ], id=’plot5′)n”, ], n”, style={‘display’: ‘flex’})n”, ])n”, )n”,”n”,# Callback function definition# TODO4: Add 5 ouput components@app.callback( [Output(component_id=’plot1′, component_property=’children’),n”, Output(component_id=’plot2′, component_property=’children’),n”, Output(component_id=’plot3′, component_property=’children’),n”, Output(component_id=’plot4′, component_property=’children’),n”, Output(component_id=’plot5′, component_property=’children’)n”, ],n”, [Input(component_id=’input-type’, component_property=’value’),n”, Input(component_id=’input-year’, component_property=’value’)n”, ],n”, # REVIEW4: Holding output state till user enters all the form information. In this case, it will be chart type and yearn”, [State(“plot1″”

Categorized as n""

Leave a comment

Your email address will not be published. Required fields are marked *