evelyn / project.py
evelyn-lo's picture
Upload folder using huggingface_hub
37c870e verified
import streamlit as st
import pandas as pd
import numpy as np
#string
s = "Here's our first attempt to create a column"
#s
####################################### 2d data frame
df = pd.DataFrame({
"first column": [1, 2, 3, 4],
"second column": [10, 20, 30, 40]
})
#np generates makes n-dimensional homogeneous objects (10x20 table)
dataframe = np.random.randn(10, 20)
#pd generates two-dimensional data (10x20 table with labels columns)
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))
)
#axis = 0 refer to column
#st.dataframe(dataframe2.style.highlight_max(axis=0))
#st.dataframe(dataframe)
#st.table(df)
############################################ chart
chart_data = pd.DataFrame(
np.random.randn(20, 3),
columns = ['a', 'b', 'd'])
#st.line_chart(chart_data)
############################################ map
map_data = pd.DataFrame(
np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
columns = ["lat", "lon"])
#st.map(map_data)
########################################### widget
x = st.slider("x")
st.write(x, "squared is", x*x)
st.text_input("your name", key = "name")
#access usingst.session_state anytime
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)
)