-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
80 lines (56 loc) · 1.93 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import streamlit as st
from dbhelper import DB
import plotly.graph_objects as go
import plotly.express as px
db = DB()
# left hand sidebar
st.sidebar.title('Flights Analytics')
# adding drop-down
user_option = st.sidebar.selectbox('Menu',['Select One','Check Flights','Analytics'])
if user_option == 'Check Flights':
st.title('Check Flights')
# check boxes
col1,col2 = st.columns(2)
# fetching names of city
city = db.fetch_city_names()
# creating first dropdown for source
with col1:
source_city = st.selectbox('Source city',sorted(city))
# creating second dropdown for destination
with col2:
destination_city = st.selectbox('Destination city',sorted(city))
# creating button to search
if st.button('Search'):
results = db.fetch_all_flights(source_city,destination_city)
# displaying all results as dataframe
st.dataframe(results)
elif user_option == 'Analytics':
st.title('Analytics')
# fetching airline name and frequency
airline,frequency = db.fetch_airline_frequency()
#pie-chart for airline frquency
fig = go.Figure(
go.Pie(
labels = airline,
values = frequency,
hoverinfo = 'label + percent',
textinfo = 'value'
))
st.header("Pie chart")
st.plotly_chart(fig)
# fetching city name and frequency of flights
city_name,freq = db.busy_airport()
# bar-graph for airline freq per city using plotly.express
st.header("Bar chart")
fig = px.bar(
x = city_name,
y = freq
)
# Customize the layout with titles and labels
fig.update_layout(
title="Frequency of Flights per City",
xaxis_title="City",
yaxis_title="Frequency")
st.plotly_chart(fig, theme='streamlit',use_container_width=True)
else:
st.title('tell about the project')