timmy / Streamlit 資料視覺化與互動選擇
0 喜歡
0 分支
1 檔案
最後活躍 10 months ago
此範例展示如何使用 Streamlit 建立互動式數據視覺化,包含多重選擇 (multiselect) 和切換開關 (toggle) 來調整數據顯示,並透過 line_chart 繪製折線圖,讓使用者輕鬆分析數據趨勢。
| 1 | import streamlit as st |
| 2 | import pandas as pd |
| 3 | import numpy as np |
| 4 | |
| 5 | st.write("Streamlit supports a wide range of data visualizations, including [Plotly, Altair, and Bokeh charts](https://docs.streamlit.io/develop/api-reference/charts). 📊 And with over 20 input widgets, you can easily make your data interactive!") |
| 6 | |
| 7 | all_users = ["Alice", "Bob", "Charly"] |
| 8 | with st.container(border=True): |
| 9 | users = st.multiselect("Users", all_users, default=all_users) |
| 10 | rolling_average = st.toggle("Rolling average") |
上一頁
下一頁