-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_data_dashboard.py
More file actions
64 lines (50 loc) · 2.34 KB
/
Copy pathauto_data_dashboard.py
File metadata and controls
64 lines (50 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import streamlit as st
import pandas as pd
import plotly.express as px
st.set_page_config(page_title="Auto Data Dashboard", layout="wide")
st.title("📊 Auto Data Dashboard from Excel/CSV")
st.markdown("""
#### 📬 Ενδιαφέρεσαι για custom αναλύσεις;
📩 Δες το Fiverr Gig μου: [https://www.fiverr.com/stathispa
""")
uploaded_file = st.file_uploader("Upload your Excel or CSV file", type=["csv", "xlsx"])
if uploaded_file:
if uploaded_file.name.endswith(".csv"):
df = pd.read_csv(uploaded_file)
else:
df = pd.read_excel(uploaded_file)
st.subheader("Preview of Data")
st.dataframe(df.head())
with st.expander("📌 Basic Statistics"):
st.write(df.describe(include='all'))
# Filtering Options
st.sidebar.header("🔎 Filters")
if 'Product' in df.columns:
products = st.sidebar.multiselect("Select Product", df['Product'].unique(), default=df['Product'].unique())
df = df[df['Product'].isin(products)]
if 'Region' in df.columns:
regions = st.sidebar.multiselect("Select Region", df['Region'].unique(), default=df['Region'].unique())
df = df[df['Region'].isin(regions)]
if 'Date' in df.columns:
df['Date'] = pd.to_datetime(df['Date'])
date_range = st.sidebar.date_input("Select Date Range", [df['Date'].min(), df['Date'].max()])
if len(date_range) == 2:
start_date = pd.to_datetime(date_range[0])
end_date = pd.to_datetime(date_range[1])
df = df[(df['Date'] >= start_date) & (df['Date'] <= end_date)]
# Charts
st.subheader("📈 Visualizations")
col1, col2 = st.columns(2)
with col1:
if 'Total Revenue' in df.columns and 'Product' in df.columns:
fig1 = px.bar(df, x='Product', y='Total Revenue', color='Region', barmode='group')
st.plotly_chart(fig1, use_container_width=True)
with col2:
if 'Date' in df.columns and 'Total Revenue' in df.columns:
fig2 = px.line(df, x='Date', y='Total Revenue', color='Product')
st.plotly_chart(fig2, use_container_width=True)
# Export Filtered Data
st.subheader("📤 Export Filtered Data")
st.download_button("Download CSV", df.to_csv(index=False), file_name="filtered_data.csv", mime="text/csv")
else:
st.info("Please upload a CSV or Excel file to get started.")