-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
executable file
·46 lines (37 loc) · 1.09 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
import streamlit as st
import pandas as pd
import numpy as np
from spatial import gazetteer
from airnow_connection import AirnowConnection
st.set_page_config(
page_title="Weather",
page_icon="tornado",
layout="wide",
)
st.title("Current Air Quality Monitor Readings")
st.subheader("Only works on US ZIP codes with a monitoring station within 20mi. Data from airnow.gov")
conn = st.connection("airnow", type=AirnowConnection)
columns = [
"Site Name",
"Latitude",
"Longitude",
"PM2.5",
"PM10",
"OZONE",
"Station Distance",
"Station Direction"]
df = pd.DataFrame(np.zeros((0,len(columns))), columns=columns, index=[])
with st.form(key="my_form"):
_ = st.text_input(
"Zip code",
"",
key="zip_code")
st.form_submit_button("Lookup")
if st.session_state.zip_code != "":
with st.spinner("Loading Data"):
results = conn.query(st.session_state.zip_code)
if results is None:
st.text("Error: invalid zip code or server issues")
else:
df = results
st.dataframe(df, use_container_width=True, hide_index=True)