ChaiHun commited on
Commit
956a542
1 Parent(s): 8033fc5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+
5
+ st.title('Uber pickups in NYC')
6
+
7
+ DATE_COLUMN = 'date/time'
8
+ DATA_URL = ('https://s3-us-west-2.amazonaws.com/'
9
+ 'streamlit-demo-data/uber-raw-data-sep14.csv.gz')
10
+
11
+ @st.cache
12
+ def load_data():
13
+ data = pd.read_csv(DATA_URL)
14
+ lowercase = lambda x: str(x).lower()
15
+ data.rename(lowercase, axis='columns', inplace=True)
16
+ data.drop(columns='base', inplace=True)
17
+ data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
18
+ return data
19
+
20
+ data_load_state = st.text('Loading data...')
21
+ data = load_data()
22
+ data_load_state.text("Done! (using st.cache)")
23
+
24
+ if st.checkbox('Show raw data'):
25
+ st.subheader('Raw data')
26
+ st.write(data)
27
+
28
+ st.subheader('Number of pickups by hour')
29
+ hist_values = np.histogram(data[DATE_COLUMN].dt.hour, bins=24, range=(0,24))[0]
30
+ st.bar_chart(hist_values)
31
+
32
+ # Some number in the range 0-23
33
+ hour_to_filter = st.slider('hour', 0, 23, 17)
34
+ filtered_data = data[data[DATE_COLUMN].dt.hour == hour_to_filter]
35
+
36
+ st.subheader('Map of all pickups at %s:00' % hour_to_filter)
37
+ st.map(filtered_data)