examples.py
This commit is contained in:
82
examples.py
Normal file
82
examples.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# start with: streamlit run examples.py
|
||||
import streamlit as st
|
||||
|
||||
|
||||
st.write("# Hello World !")
|
||||
|
||||
|
||||
import pandas as pd
|
||||
df = pd.DataFrame({
|
||||
'first column': [1, 2, 3, 4],
|
||||
'second column': [10, 20, 30, 40]
|
||||
})
|
||||
df
|
||||
|
||||
|
||||
st.table(df)
|
||||
|
||||
|
||||
import pandas as pd
|
||||
st.map(pd.DataFrame({'lat':[52.3642], 'lon':[13.0906]}), zoom=17, size=5)
|
||||
|
||||
|
||||
import streamlit as st
|
||||
x = st.slider('x', 32, 233) # 👈 this is a widget
|
||||
st.write(x, 'squared is', x * x)
|
||||
|
||||
|
||||
st.text_input("Your name", key="name")
|
||||
# You can access the value at any point with:
|
||||
st.session_state.name
|
||||
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
if st.checkbox('Show dataframe'):
|
||||
chart_data = pd.DataFrame(
|
||||
np.random.randn(20, 3),
|
||||
columns=['a', 'b', 'c'])
|
||||
chart_data
|
||||
|
||||
|
||||
import pandas as pd
|
||||
df = pd.DataFrame({
|
||||
'first column': [1, 2, 3, 4],
|
||||
'second column': [10, 20, 30, 40]
|
||||
})
|
||||
option = st.selectbox(
|
||||
'Which number do you like best?',
|
||||
df['first column'])
|
||||
'You selected: ', option
|
||||
|
||||
|
||||
add_selectbox = st.sidebar.selectbox(
|
||||
'How would you like to be contacted?',
|
||||
('Email', 'Home phone', 'Mobile phone')
|
||||
)
|
||||
# Add a slider to the sidebar:
|
||||
add_slider = st.sidebar.slider(
|
||||
'Select a range of values',
|
||||
0.0, 100.0, (25.0, 75.0)
|
||||
)
|
||||
|
||||
add_selectbox
|
||||
add_slider
|
||||
|
||||
|
||||
left_column, right_column = st.columns(2)
|
||||
# You can use a column just like st.sidebar:
|
||||
left_column.button('Press me!')
|
||||
# Or even better, call Streamlit functions inside a "with" block:
|
||||
with right_column:
|
||||
chosen = st.radio(
|
||||
'Sorting hat',
|
||||
("Gryffindor", "Ravenclaw", "Hufflepuff", "Slytherin"))
|
||||
st.write(f"You are in {chosen} house!")
|
||||
|
||||
|
||||
st.progress(80)
|
||||
|
||||
st.text_area("Your text", key="te")
|
||||
st.session_state.te
|
||||
Reference in New Issue
Block a user