📘 Introduction

Data is only as useful as your ability to explore and understand it. But building an interface to analyze and visualize your DataFrame often feels like a full-blown front-end project. That’s where Streamlit saves the day.

In this tutorial, you’ll learn how to build a data app containing an interactive dashboard to explore any Pandas DataFrame — all with just Python. No JavaScript, no CSS, no hassle.

✅ Prerequisites

Before we begin, make sure you have the following ready:

☑️ Python 3.8 or later installed

💡
No front-end skills needed — Streamlit handles that for you! 🎨

⚙️1️⃣ Install Libraries

Open your terminal and run the following to install the required libraries:

pip install streamlit pandas

💻2️⃣ Build the App

Create a new file in your working directory and name it app.py. Open it in your favorite code editor and paste the following code:

import streamlit as st
import pandas as pd

# App title
st.title("📊 Interactive DataFrame Dashboard")

# Upload CSV file
uploaded_file = st.file_uploader(
    "Upload your CSV file",
    type=["csv"]
)

if uploaded_file is not None:
    df = pd.read_csv(uploaded_file)
    st.success("Data loaded successfully!")

    # Show preview
    st.subheader("🔍 Data Preview")
    st.dataframe(df.head())

    # Select columns to visualize
    st.subheader("📌 Column Selector")
    selected_columns = st.multiselect(
        "Choose columns to display",
        df.columns.tolist(),
        default=df.columns.tolist()
    )
    st.dataframe(df[selected_columns])

    # Basic statistics
    st.subheader("📈 Summary Statistics")
    st.write(df[selected_columns].describe())

    # Simple plot
    st.subheader("📊 Plot a Column")
    numeric_columns = (
        df.select_dtypes( include="number")
        .columns.tolist()
    )
    column_to_plot = st.selectbox(
        "Choose a numeric column to plot",
        numeric_columns
    )
    st.line_chart(df[column_to_plot])

else:
    st.info("Please upload a CSV file to get started.")

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In