Created
July 27, 2023 12:27
-
-
Save kururu-abdo/6dd5141057c58a5309c2e899d268788b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import required packages | |
import pandas as pd | |
import plotly.express as px | |
import dash | |
import dash_html_components as html | |
import dash_core_components as dcc | |
# Read the airline data into pandas dataframe | |
airline_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}) | |
# Randomly sample 500 data points. Setting the random state to be 42 so that we get same result. | |
data = airline_data.sample(n=500, random_state=42) | |
# Pie Chart Creation | |
fig = px.pie(data, values='Flights', names='DistanceGroup', title='Distance group proportion by flights') | |
# Create a dash application | |
app = dash.Dash(__name__) | |
# Get the layout of the application and adjust it. | |
# Create an outer division using html.Div and add title to the dashboard using html.H1 component | |
# Add description about the graph using HTML P (paragraph) component | |
# Finally, add graph component. | |
app.layout = html.Div(children=[html.H1('Airline Dashboard',style={'textAlign': 'center', 'color': '#503D36', 'font-size': 40}), | |
html.P('Proportion of distance group (250 mile distance interval group) by flights.', style={'textAlign':'center', 'color': '#F57241'}), | |
dcc.Graph(figure=fig), | |
]) | |
# Run the application | |
if __name__ == '__main__': | |
app.run_server() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment