|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
import numpy as np |
|
|
import time |
|
|
|
|
|
x = st.slider('x') |
|
|
st.write(x, 'squared is', x * x) |
|
|
|
|
|
name = st.text_input("Your name", key="name") |
|
|
st.write(f'Hello {name}') |
|
|
|
|
|
|
|
|
add_selectbox = st.sidebar.selectbox( |
|
|
'How would you like to be contacted?', |
|
|
('Email', 'Home phone', 'Mobile phone') |
|
|
) |
|
|
|
|
|
|
|
|
add_slider = st.sidebar.slider( |
|
|
'Select a range of values', |
|
|
0.0, 100.0, (25.0, 75.0) |
|
|
) |
|
|
|
|
|
left_column, right_column = st.columns(2) |
|
|
|
|
|
r=left_column.button('Press me!') |
|
|
st.write(f'button {r}') |
|
|
|
|
|
latest_iteration = st.empty() |
|
|
bar = st.progress(0) |
|
|
for i in range(100): |
|
|
|
|
|
latest_iteration.text(f'Iteration {i+1}') |
|
|
bar.progress(i + 1) |
|
|
time.sleep(0.1) |
|
|
|
|
|
|
|
|
with right_column: |
|
|
chosen = st.radio( |
|
|
'Sorting hat', |
|
|
("Gryffindor", "Ravenclaw", "Hufflepuff", "Slytherin")) |
|
|
st.write(f"You are in {chosen} house!") |
|
|
|
|
|
|
|
|
st.write("Here's our first attempt at using data to create a table:") |
|
|
st.write([34,56]) |
|
|
st.write(pd.DataFrame({ |
|
|
'first column': [1, 2, 3, 4], |
|
|
'second column': [10, 20, 30, 40] |
|
|
})) |
|
|
|
|
|
dataframe = pd.DataFrame( |
|
|
np.random.randn(10, 20), |
|
|
columns=('col %d' % i for i in range(20))) |
|
|
|
|
|
st.dataframe(dataframe.style.highlight_max(axis=0)) |
|
|
st.table(dataframe.style.highlight_max(axis=0)) |
|
|
|
|
|
|
|
|
map_data = pd.DataFrame( |
|
|
np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4], |
|
|
columns=['lat', 'lon']) |
|
|
|
|
|
st.map(map_data) |
|
|
|