|
import streamlit as st |
|
import pandas as pd |
|
|
|
import numpy as np |
|
|
|
|
|
|
|
s = "Here's our first attempt to create a column" |
|
|
|
|
|
|
|
|
|
df = pd.DataFrame({ |
|
"first column": [1, 2, 3, 4], |
|
"second column": [10, 20, 30, 40] |
|
}) |
|
|
|
|
|
dataframe = np.random.randn(10, 20) |
|
|
|
|
|
dataframe2 = pd.DataFrame( |
|
np.random.randn(10, 20), |
|
columns = ('col %d' % i for i in range(20)), |
|
index = ('row %d' % i for i in range(10)) |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chart_data = pd.DataFrame( |
|
np.random.randn(20, 3), |
|
columns = ['a', 'b', 'd']) |
|
|
|
|
|
|
|
|
|
|
|
map_data = pd.DataFrame( |
|
np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4], |
|
columns = ["lat", "lon"]) |
|
|
|
|
|
|
|
|
|
x = st.slider("x") |
|
st.write(x, "squared is", x*x) |
|
|
|
st.text_input("your name", key = "name") |
|
|
|
|
|
st.session_state.name |
|
|
|
if st.checkbox("Show dataframe"): |
|
chart_data = pd.DataFrame( |
|
np.random.randn(20, 3), |
|
columns = ["a", "b", "c"] |
|
) |
|
chart_data |
|
|
|
|
|
df = pd.DataFrame({ |
|
"first column": [1, 2, 3, 4], |
|
"second column": [10, 20, 30, 40] |
|
|
|
}) |
|
|
|
st.write(df) |
|
|
|
|
|
option2 = st.selectbox( |
|
"Which column do you like best?", |
|
[""] + list(df.columns) |
|
) |
|
|
|
if option2: |
|
option = st.selectbox( |
|
"Which nuber do you like best?", |
|
df[option2] |
|
) |
|
|
|
"You selected: ", option |
|
|
|
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) |
|
) |
|
|
|
|
|
|