Spaces:
Build error
Build error
Update sidebar-example.py
Browse files- sidebar-example.py +29 -0
sidebar-example.py
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
|
| 5 |
+
st.title("Dashboard Example")
|
| 6 |
+
|
| 7 |
+
# File uploader
|
| 8 |
+
uploaded_file = st.file_uploader("Upload CSV for Dashboard", type=["csv"])
|
| 9 |
+
|
| 10 |
+
if uploaded_file:
|
| 11 |
+
data = pd.read_csv(uploaded_file)
|
| 12 |
+
st.sidebar.title("Dashboard Controls")
|
| 13 |
+
|
| 14 |
+
# Sidebar controls
|
| 15 |
+
column = st.sidebar.selectbox("Select column to analyze:", data.columns)
|
| 16 |
+
chart_type = st.sidebar.selectbox("Choose chart type:", ["Bar", "Line", "Scatter"])
|
| 17 |
+
|
| 18 |
+
# Display summary
|
| 19 |
+
st.write("Summary Statistics:")
|
| 20 |
+
st.write(data.describe())
|
| 21 |
+
|
| 22 |
+
# Generate chart
|
| 23 |
+
if chart_type == "Bar":
|
| 24 |
+
st.bar_chart(data[column])
|
| 25 |
+
elif chart_type == "Line":
|
| 26 |
+
st.line_chart(data[column])
|
| 27 |
+
else:
|
| 28 |
+
fig = px.scatter(data, x=data.index, y=column)
|
| 29 |
+
st.plotly_chart(fig)
|