Drop files here
or click to upload
import streamlit as st
import pandas as pd
# ----------------------------
# Title & Introduction
# ----------------------------
st.title("🧠 Mental Health in Tech Survey")
st.write("""
This interactive Streamlit app explores insights from the
**Mental Health in Tech Survey** dataset.
Upload your dataset and explore distributions, treatment trends,
and demographics interactively.
""")
# ----------------------------
# Upload Dataset
# ----------------------------
uploaded_file = st.file_uploader("📂 Upload the Survey Dataset (CSV)", type=["csv"])
if uploaded_file:
df = pd.read_csv(uploaded_file)
st.success("✅ File Uploaded Successfully!")
# ----------------------------
# Show Data
# ----------------------------
if st.checkbox("👀 Show Raw Data"):
st.dataframe(df.head())
# ----------------------------
# Dataset Info
# ----------------------------
st.subheader("📊 Dataset Overview")
st.write("Shape of dataset:", df.shape)
st.write("Columns:", df.columns.tolist())
# Missing values
st.write("Missing values per column:")
st.write(df.isnull().sum())
# ----------------------------
# Gender Distribution
# ----------------------------
if "Gender" in df.columns:
st.subheader("👩💻 Gender Distribution")
gender_counts = df["Gender"].value_counts()
st.bar_chart(gender_counts)
# ----------------------------
# Country Distribution
# ----------------------------
if "Country" in df.columns:
st.subheader("🌍 Country Distribution (Top 15)")
country_counts = df["Country"].value_counts().head(15)
st.bar_chart(country_counts)
# ----------------------------
# Treatment Distribution
# ----------------------------
if "treatment" in df.columns:
st.subheader("💊 Treatment vs No Treatment")
treatment_counts = df["treatment"].value_counts()
st.bar_chart(treatment_counts)
# ----------------------------
# Work Interference
# ----------------------------
if "work_interfere" in df.columns:
st.subheader("📌 Work Interference due to Mental Health")
work_counts = df["work_interfere"].value_counts()
st.bar_chart(work_counts)
# ----------------------------
# Self Employed
# ----------------------------
if "self_employed" in df.columns:
st.subheader("💼 Self-Employed Distribution")
se_counts = df["self_employed"].value_counts()
st.bar_chart(se_counts)
# ----------------------------
# Age Distribution
# ----------------------------
if "Age" in df.columns:
st.subheader("📈 Age Distribution")
st.line_chart(df["Age"].value_counts().sort_index())
# ----------------------------
# Footer
# ----------------------------
st.write("---")
st.caption("📊 Built with Streamlit | Mental Health in Tech Survey Analysis")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?