https://learn-hero08.streamlit.app/
pip install streamlit
streamlit hello
streamlit run main.py
st.title('Streamlit horomi(^o^)v')
df=pd.DataFrame(
np.random.rand(20,3),
columns=['a','b','c']
)
df
st.line_chart(df)
https://docs.streamlit.io/library/api-reference/charts/st.line_chart
st.area_chart(df)
https://docs.streamlit.io/library/api-reference/charts/st.area_chart
こんな機能も標準である👀
df=pd.DataFrame(
np.random.rand(100,2)/[50,50]+[35.69,139.70],
columns=['lat','lon']
)
st.map(df)
https://docs.streamlit.io/library/api-reference/charts/st.map
from PIL import Image
img=Image.open('IMG_1720.PNG')
st.image(img,caption='horomi',use_column_width=True)
https://docs.streamlit.io/library/api-reference/media/st.image
video_file = open('obsidian-ai.mov', 'rb')
video_bytes = video_file.read()
st.video(video_bytes)
if st.checkbox('Show Image'):
img=Image.open('IMG_1720.PNG')
st.image(img,caption='horomi',use_column_width=True)
https://docs.streamlit.io/library/api-reference/widgets/st.checkbox
↓
option=st.selectbox(
'あなたが好きな数字を教えてください',
list(range(1,11))
)
'あなたの好きな数字は、',option,'です'
https://docs.streamlit.io/library/api-reference/widgets/st.selectbox
text=st.text_input('あなたの趣味を教えてください')
'あなたの趣味:',text,'です'
https://docs.streamlit.io/library/api-reference/widgets/st.text_input
condition=st.slider('あなたの今の調子は?',0,100,50)
'コンディション:',condition
https://docs.streamlit.io/library/api-reference/widgets/st.slider
↓
left_column,right_column=st.columns(2)
button=left_column.button('右カラムに文字を表示')
if button:
right_column.write('ここは右カラムです')
↓
expander=st.expander('問い合わせ')
expander.write('問い合わせ内容を書く')
https://docs.streamlit.io/library/api-reference/layout/st.expander
https://www.youtube.com/watch?v=zp-kAt1Ih5k
streamlitのバージョン確認
pip freeze| grep strea
streamlit==1.12.0
気になるBookmark 🍄