0% found this document useful (0 votes)
2 views4 pages

Project Complete Guide

The project involves creating a Streamlit sales dashboard that reads and cleans a CSV file, allowing users to filter data by Region, Category, and Date while displaying key performance indicators (KPIs), charts, and a data table. Key tasks include handling missing values, setting up the dashboard layout, and implementing various visualizations using Matplotlib and Pandas. The document outlines a step-by-step guide for building the dashboard, including specific Streamlit and Pandas functions to use.

Uploaded by

hemanimajhi189
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Project Complete Guide

The project involves creating a Streamlit sales dashboard that reads and cleans a CSV file, allowing users to filter data by Region, Category, and Date while displaying key performance indicators (KPIs), charts, and a data table. Key tasks include handling missing values, setting up the dashboard layout, and implementing various visualizations using Matplotlib and Pandas. The document outlines a step-by-step guide for building the dashboard, including specific Streamlit and Pandas functions to use.

Uploaded by

hemanimajhi189
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Complete Project Guide

Sales Dashboard — matches your [Link] exactly

1. WHAT THIS PROJECT IS


You are given a sales CSV file (sales_data.csv). Your task is to build a Streamlit webpage that reads this file, cleans it,
lets the user filter it (Region, Category, Date), and then shows KPI numbers, 3 charts, and a data table — all of which
update automatically when the filters change.

2. TASK BREAKDOWN — What to Show


What to show Columns used Chart type

Total Sales, Total Profit,


Sales, Profit, Rating KPI Cards
Avg Rating, Total Orders

Sales by Month Order_Date -> Month, Sales Line Chart

Sales by Category Category, Sales Bar Chart

Profit share by Category Category, Profit Pie Chart

Filtered raw data All columns Table

3. HANDLING NULL (MISSING) VALUES


sales_data.csv has empty cells in 2 columns: Rating and Customer_Age. Fix these BEFORE doing anything else, or
your KPI numbers and charts will be wrong.

Step 1: Check which columns have missing values


[Link]().sum()
Prints how many empty cells exist in every column.

Step 2: Fill them — rule to follow

Column Fill with Why

Rating mean() Values are close together (1-5), average represents it well.

Customer_Age median() Age can have outliers, median ignores extreme values.

df["Rating"] = df["Rating"].fillna(df["Rating"].mean())
df["Customer_Age"] = df["Customer_Age"].fillna(df["Customer_Age"].median())
Step 3: Confirm it worked — run [Link]().sum() again, both should show 0.

4. STEP BY STEP — How To Build It (Simplest Way)


1 Import streamlit, pandas, [Link].
2 Set page config with st.set_page_config(), then add [Link]().
3 Load CSV with pd.read_csv().
4 Fill missing values in Rating (mean) and Customer_Age (median) — see Section 3.
5 Convert Order_Date to real date using pd.to_datetime().
6 Create a Month column using dt.to_period('M').
7 Add sidebar filters: multiselect for Region, multiselect for Category, date_input for date range.
8 Filter the dataframe using isin() and & to combine conditions, save as df_filtered.
9 Show 4 KPI cards using [Link]() + [Link]() for Sales, Profit, Rating, Orders.
10 For Sales by Month: groupby('Month'), then [Link]() a line chart, show with [Link](plt).
11 For Sales by Category: groupby('Category'), then [Link]() a bar chart, show with [Link](plt).
12 For Profit share: groupby('Category') on Profit, then [Link]() a pie chart, show with [Link](plt).
13 Show the filtered table using [Link]().
14 Run streamlit run [Link] and test that filters update everything correctly.

5. STREAMLIT FUNCTIONS USED IN [Link]


st.set_page_config()
st.set_page_config(page_title="Sales Dashboard", layout="wide")
Use: Sets browser tab title and makes page wide. Must be the first Streamlit line.

[Link]()
[Link]("Sales Dashboard")
Use: Big main heading at the top of the page.

[Link]()
[Link]("Sales by Month")
Use: Section heading, used above each chart/table.

[Link]()
[Link]("Filters")
Use: Heading inside the left sidebar panel.

[Link]()
[Link]("Region", df["Region"].unique())
Use: Sidebar dropdown letting the user pick multiple values (used for Region and Category).

[Link].date_input()
[Link].date_input("Order Date", [start, end])
Use: Sidebar calendar picker for choosing a date range.

[Link]()
col1, col2, col3, col4 = [Link](4)
Use: Splits page into side-by-side sections, used to place KPI cards next to each other.

[Link]()
[Link]("Total Sales", df_filtered["Sales"].sum())
Use: Displays one big KPI number with a label.

[Link]()
[Link](plt)
Use: Displays the current Matplotlib chart inside the Streamlit app.

[Link]()
[Link](df_filtered)
Use: Shows the filtered data as a scrollable table.

6. PANDAS FUNCTIONS USED IN [Link]


pd.read_csv()
df = pd.read_csv("sales_data.csv")
Use: Loads the CSV file into a DataFrame.

df['col'].fillna()
df["Rating"] = df["Rating"].fillna(df["Rating"].mean())
Use: Fills missing cells in a column with a chosen value.

df['col'].mean()
df["Rating"].mean()
Use: Average of a column — used to fill Rating nulls.

df['col'].median()
df["Customer_Age"].median()
Use: Middle value of a column — used to fill Age nulls.

pd.to_datetime()
df["Order_Date"] = pd.to_datetime(df["Order_Date"])
Use: Converts text into a real date type so it can be filtered/sorted by date.

df['col'].dt.to_period()
df["Order_Date"].dt.to_period("M")
Use: Extracts Year-Month from a date, used for monthly grouping.

df['col'].unique()
df["Region"].unique()
Use: Returns the list of distinct values, used to fill dropdown options.

df['col'].isin()
df["Region"].isin(region)
Use: Keeps rows where value is inside a given list.

Boolean filtering with &


df[(df["Region"].isin(region)) & (df["Category"].isin(category))]
Use: Combines multiple filter conditions; all must be true.

df['col'].min() / max()
df["Order_Date"].min()
Use: Finds earliest/latest date — used to set default date range.

df['col'].sum()
df_filtered["Sales"].sum()
Use: Adds up all values in a column — used for KPI totals.

[Link]
df_filtered.shape[0]
Use: Returns row count — used for Total Orders KPI.

[Link]()
df_filtered.groupby("Month")["Sales"].sum()
Use: Groups rows sharing the same value, then combines another column per group. Used before every chart.

7. MATPLOTLIB FUNCTIONS USED IN [Link]


[Link]()
[Link]()
Use: Starts a fresh, empty chart. Used before every new chart so old chart settings don't carry over.

[Link]()
[Link](monthly_sales.[Link](str), monthly_sales.values)
Use: Draws a line chart — used for Sales by Month (shows trend over time).

[Link]()
[Link](category_sales.index, category_sales.values)
Use: Draws a bar chart — used for Sales by Category (compares totals).

[Link]()
[Link](category_profit, labels=category_profit.index, autopct="%1.1f%%")
Use: Draws a pie chart — used for Profit Share by Category (shows percentage split).

[Link]() / [Link]()
[Link]("Month")
[Link]("Sales")
Use: Labels the x-axis and y-axis.

[Link]()
[Link]("Sales Over Time")
Use: Adds a title above the chart.

[Link](rotation=...)
[Link](rotation=45)
Use: Rotates x-axis text so labels don't overlap.

You might also like