Nicholas Armenta commited on
Commit
4ca99af
1 Parent(s): 7bc0e4f

Getting started

Browse files
Files changed (6) hide show
  1. .vscode/settings.json +3 -0
  2. README.md +1 -0
  3. app.py +31 -3
  4. file1.csv +1 -0
  5. requiremenents.txt +0 -0
  6. requirements.txt +1 -0
.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "python.pythonPath": "/usr/bin/python3"
3
+ }
README.md CHANGED
@@ -4,6 +4,7 @@ emoji: ⚡
4
  colorFrom: green
5
  colorTo: indigo
6
  sdk: streamlit
 
7
  app_file: app.py
8
  pinned: false
9
  ---
 
4
  colorFrom: green
5
  colorTo: indigo
6
  sdk: streamlit
7
+ sdk_version: 1.0.0
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -1,6 +1,34 @@
1
- #!/usr/bin/env python3
2
  import streamlit as st
 
 
3
 
4
- x = st.slider('Select a value')
5
- st.write(x, 'squared is', x * x)
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env streamlit run
2
  import streamlit as st
3
+ import pandas as pd
4
+ import os, requests, json
5
 
6
+ API_KEY=os.environ.get('AIRNOW')
 
7
 
8
+ st.title('Data Visualization')
9
+
10
+ st.sidebar.header('')
11
+ mainPage = st.sidebar.selectbox(
12
+ 'Choose from some examples...',
13
+ ['Weather map', 'Growth', 'Adjustment'])
14
+
15
+
16
+ if mainPage == 'Weather map':
17
+ BASE_URL = 'https://www.airnowapi.org/aq/observation/zipCode/historical/?format=application/json'
18
+ startDate = st.date_input('Choose a date...')
19
+ zipCode = int(st.number_input('Enter your zip code...', min_value=0, max_value=99999, value=75019, step=1))
20
+ distance = st.slider('Choose a radius...',0,100,10,5)
21
+ ARGS = f'&zipCode={zipCode}&date={startDate.year}-{startDate.month}-{startDate.day-2}T00-0000&distance={distance}&API_KEY={API_KEY}'
22
+ QUERY_URL = f'{BASE_URL}{ARGS}'
23
+ r = requests.get(QUERY_URL)
24
+ if r.status_code != 200:
25
+ st.write('Couldn\'t get data!')
26
+
27
+ ozone = json.loads(r.text)[0]
28
+ date = ozone["DateObserved"]
29
+ aqi = ozone["AQI"]
30
+ description = ozone["Category"]["Name"]
31
+ lat, lon = (ozone["Latitude"], ozone["Longitude"])
32
+ st.write(f'Date: {date}, AQI: {aqi}, Level: {description}')
33
+ mapData = pd.DataFrame({'lat': [lat, lat+10], 'lon': [lon, lon+10]})
34
+ st.map(mapData)
file1.csv ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"DateObserved":"2021-11-10 ","HourObserved":0,"LocalTimeZone":"CST","ReportingArea":"Dallas-Fort Worth","StateCode":"TX","Latitude":32.767,"Longitude":-96.783,"ParameterName":"OZONE","AQI":42,"Category":{"Number":1,"Name":"Good"}},{"DateObserved":"2021-11-10 ","HourObserved":0,"LocalTimeZone":"CST","ReportingArea":"Dallas-Fort Worth","StateCode":"TX","Latitude":32.767,"Longitude":-96.783,"ParameterName":"PM2.5","AQI":24,"Category":{"Number":1,"Name":"Good"}}]
requiremenents.txt DELETED
File without changes
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pandas