Spaces:
Runtime error
Runtime error
Synced repo using 'sync_with_huggingface' Github Action
Browse files
app.py
CHANGED
@@ -1,4 +1,42 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_resource
|
12 |
+
def load_data(nrows):
|
13 |
+
data = pd.read_csv(DATA_URL, nrows=nrows)
|
14 |
+
lowercase = lambda x: str(x).lower()
|
15 |
+
data.rename(lowercase, axis='columns', inplace=True)
|
16 |
+
data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
|
17 |
+
return data
|
18 |
+
|
19 |
+
data_load_state = st.text('Loading data...')
|
20 |
+
data = load_data(10000)
|
21 |
+
data_load_state.text("Done! (using st.cache)")
|
22 |
+
|
23 |
+
if st.checkbox('Show raw data'):
|
24 |
+
st.subheader('Raw data')
|
25 |
+
st.write(data)
|
26 |
+
|
27 |
+
st.subheader('Number of pickups by hour')
|
28 |
+
hist_values = np.histogram(data[DATE_COLUMN].dt.hour, bins=24, range=(0,24))[0]
|
29 |
+
st.bar_chart(hist_values)
|
30 |
+
|
31 |
+
# Some number in the range 0-23
|
32 |
+
hour_to_filter = st.slider('hour', 0, 23, 17)
|
33 |
+
filtered_data = data[data[DATE_COLUMN].dt.hour == hour_to_filter]
|
34 |
+
|
35 |
+
st.subheader('Map of all pickups at %s:00' % hour_to_filter)
|
36 |
+
st.map(filtered_data)
|
37 |
+
|
38 |
+
uploaded_file = st.file_uploader("Choose a file")
|
39 |
+
if uploaded_file is not None:
|
40 |
+
st.write(uploaded_file.name)
|
41 |
+
bytes_data = uploaded_file.getvalue()
|
42 |
+
st.write(len(bytes_data), "bytes")
|