-
Notifications
You must be signed in to change notification settings - Fork 31
/
streamlit_app.py
53 lines (46 loc) · 1.7 KB
/
streamlit_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
import streamlit as st
from collections import namedtuple
import math
import pandas as pd
import numpy as np
import plost # this package is used to create plots/charts within streamlit
from PIL import Image # this package is used to put images within streamlit
#from api_connection import get_data_from_api # keep this commented if not using it otherwise brakes the app
# Page setting
st.set_page_config(layout="wide")
with open('style.css') as f:
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
# Data
seattle_weather = pd.read_csv('https://raw.githubusercontent.com/tvst/plost/master/data/seattle-weather.csv', parse_dates=['date'])
stocks = pd.read_csv('https://raw.githubusercontent.com/dataprofessor/data/master/stocks_toy.csv')
# replace the previous data with your own streamed data from API
### Here starts the web app design
# Row A
a1, a2, a3 = st.columns(3)
a1.image(Image.open('streamlit-logo-secondary-colormark-darktext.png'))
a2.metric("Wind", "9 mph", "-8%")
a3.metric("Humidity", "86%", "4%")
# Row B
b1, b2, b3, b4 = st.columns(4)
b1.metric("Temperature", "70 °F", "1.2 °F")
b2.metric("Wind", "9 mph", "-8%")
b3.metric("Humidity", "86%", "4%")
b4.metric("Humidity", "86%", "4%")
# Row C
c1, c2 = st.columns((7,3))
with c1:
st.markdown('### Heatmap') # text is created with markdown
plost.time_hist( # histogram
data=seattle_weather,
date='date',
x_unit='week',
y_unit='day',
color='temp_max',
aggregate='median',
legend=None)
with c2:
st.markdown('### Bar chart')
plost.donut_chart( # donut charts
data=stocks,
theta='q2',
color='company')