Spaces:
Sleeping
Sleeping
one more time
Browse files- README.md +4 -4
- inClass_script_week10.py +51 -0
- requirements.txt +4 -2
README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
---
|
2 |
-
title: Example
|
3 |
emoji: 🏢
|
4 |
-
colorFrom:
|
5 |
colorTo: gray
|
6 |
sdk: streamlit
|
7 |
-
sdk_version: 1.
|
8 |
-
app_file:
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
|
|
1 |
---
|
2 |
+
title: In Class Example (Week 11)
|
3 |
emoji: 🏢
|
4 |
+
colorFrom: green
|
5 |
colorTo: gray
|
6 |
sdk: streamlit
|
7 |
+
sdk_version: 1.39.0
|
8 |
+
app_file: inClass_script_week10.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
inClass_script_week10.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# we will often times use an app.py instead of a workbook so here is just a placeholder for that kind of file as well!
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
st.title('This is my fancy app!')
|
5 |
+
|
6 |
+
st.header("This is a header")
|
7 |
+
st.subheader('This is a subheader')
|
8 |
+
|
9 |
+
st.text('This is some text.')
|
10 |
+
|
11 |
+
|
12 |
+
# 1. Layout elements
|
13 |
+
col1,col2 = st.columns(2)
|
14 |
+
col1.write('This is thing 1')
|
15 |
+
col2.write('This is thing 2')
|
16 |
+
|
17 |
+
# 2. Images
|
18 |
+
st.subheader('Images')
|
19 |
+
st.image('https://i.redd.it/on-a-scale-of-1-10-how-derpy-is-she-v0-z8gtdwu5n5zb1.jpg?width=3024&format=pjpg&auto=webp&s=345e7e1d5b45f20c733e497a9f746f4cbd3a61da',
|
20 |
+
width=200,
|
21 |
+
caption='A thinly veiled excuse for a cute corg!')
|
22 |
+
|
23 |
+
|
24 |
+
import numpy as np
|
25 |
+
|
26 |
+
img_data = np.random.random((200,200))
|
27 |
+
st.image(img_data,
|
28 |
+
caption='Random numpy data')
|
29 |
+
|
30 |
+
st.header('Altair in Streamlit')
|
31 |
+
import altair as alt
|
32 |
+
|
33 |
+
mobility_url = 'https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/mobility.csv'
|
34 |
+
|
35 |
+
scatters = alt.Chart(mobility_url).mark_point().encode(
|
36 |
+
x = 'Mobility:Q',
|
37 |
+
y=alt.Y('Population:Q', scale=alt.Scale(type='log')),
|
38 |
+
color=alt.Color('Income:Q',
|
39 |
+
scale=alt.Scale(scheme='sinebow'),
|
40 |
+
bin=alt.Bin(maxbins=5))
|
41 |
+
)
|
42 |
+
scatters
|
43 |
+
|
44 |
+
st.markdown("""Add in altair charts with layout elements
|
45 |
+
""")
|
46 |
+
|
47 |
+
col1,col2 = st.columns([0.7, 0.25])
|
48 |
+
col1.altair_chart(scatters, theme='streamlit',
|
49 |
+
use_container_width=True)
|
50 |
+
col2.markdown("Here is some text on the side of the plot.")
|
51 |
+
col2.image('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQAXjp6mzNlkMEEiMomUfTEMiX8NHpopoyyXg&s')
|
requirements.txt
CHANGED
@@ -1,3 +1,5 @@
|
|
1 |
-
streamlit
|
2 |
altair
|
3 |
-
|
|
|
|
|
|
1 |
+
streamlit==1.39.0
|
2 |
altair
|
3 |
+
numpy
|
4 |
+
matplotlib
|
5 |
+
pandas
|