Contents
Project 1 - Sales Data Analysis
Sales analysis is a useful beginner-friendly project because it combines data cleaning, aggregation, and visualization.
Imagine a company provides a CSV file containing order dates, products, quantities, and prices. The objective is to identify revenue trends and the best-performing products.
Step 1: Load and Inspect the Dataset
import pandas as pd
df = pd.read_csv("sales.csv")
print(df.head())
print(df.info())
print(df.isnull().sum())
The dataset might contain columns such as OrderDate, Product, Quantity, and UnitPrice.
Step 2: Clean and Transform the Data
df["OrderDate"] = pd.to_datetime(
df["OrderDate"],
errors="coerce"
)
df["Quantity"] = pd.to_numeric(
df["Quantity"],
errors="coerce"
)
df["UnitPrice"] = pd.to_numeric(
df["UnitPrice"],
errors="coerce"
)
df = df.dropna(
subset=["OrderDate", "Product", "Quantity", "UnitPrice"]
)
df["Revenue"] = df["Quantity"] * df["UnitPrice"]
This converts columns to suitable data types, removes records with missing values in essential fields, and calculates revenue. In a real project, investigate why records are missing before deciding whether to remove them.
Step 3: Analyze Product Performance
product_sales = (
df.groupby("Product")["Revenue"]
.sum()
.sort_values(ascending=False)
)
print(product_sales.head(10))
This identifies the products with the highest total revenue.
Step 4: Visualize the Results
import matplotlib.pyplot as plt
product_sales.head(10).sort_values().plot(
kind="barh",
figsize=(9, 5)
)
plt.title("Top 10 Products by Revenue")
plt.xlabel("Revenue")
plt.ylabel("Product")
plt.tight_layout()
plt.show()
Possible project outcomes:
- Identify products generating the most revenue.
- Compare monthly sales performance.
- Find periods with declining sales.
- Help business teams plan inventory and promotions.
For a portfolio project, include the business question, data-cleaning decisions, visualizations, and actionable findings rather than submitting code alone.
Python for Data Science
Vishalini A








