Chen0324 commited on
Commit
bf83b34
·
1 Parent(s): dd992e1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+ import altair as alt
5
+ import duckdb
6
+
7
+ con = duckdb.connect(database='Job.db', read_only=True)
8
+
9
+ # Countries
10
+ query="""
11
+ SELECT *
12
+ FROM job
13
+ """
14
+ Countries=list(con.execute(query).df().columns)[2:]
15
+
16
+
17
+ st.subheader('Investingation')
18
+
19
+ col1, col2 = st.columns(2)
20
+
21
+ with col1:
22
+ query="""
23
+ SELECT
24
+ DISTINCT variable
25
+ From job
26
+ ORDER BY variable
27
+ """
28
+
29
+ kinds=con.execute(query).df()
30
+ kind = st.selectbox('Kind of Statistics',kinds)
31
+ with col2:
32
+ country = st.selectbox('Country',Countries)
33
+
34
+
35
+ result_df = con.execute("""
36
+ SELECT
37
+ *
38
+ FROM Job
39
+ WHERE variable=?
40
+ """, [kind]).df()
41
+
42
+ chart = alt.Chart(result_df).mark_circle().encode(
43
+ x = 'date',
44
+ y = country,
45
+ #color = 'carrier'
46
+ ).interactive()
47
+ st.altair_chart(chart, theme="streamlit", use_container_width=True)