Data Analysis Project Overview
Data analysis converts raw business data into useful information for decision-making. This project follows a professional workflow using Python, Pandas, NumPy and visualization techniques.
Data analysis is the process of collecting, cleaning, transforming and examining data to answer business or technical questions.
Typical Professional Questions
- Which products generate the most revenue?
- Which region has the highest sales?
- How are sales changing over time?
- Which customers are most valuable?
- Where are unusual transactions occurring?
- Which factors are associated with higher profit?
- Are business KPIs improving or declining?
This workflow is reusable across sales analytics, marketing, finance, operations, customer analytics and many other domains.
| Technology | Purpose |
|---|---|
| Python | Programming and automation |
| Pandas | Data manipulation and analysis |
| NumPy | Numerical computation |
| Matplotlib | Data visualization |
| Seaborn | Statistical visualization |
| Jupyter | Interactive analysis |
| SQL | Database querying |
pip install pandas numpy matplotlib seaborn jupyter
Our project will analyze a simplified sales dataset containing customer, product, region, revenue, cost and transaction information.
import pandas as pd
data = {
"date": [
"2026-01-05",
"2026-01-07",
"2026-01-12",
"2026-02-03",
"2026-02-14",
"2026-03-02",
"2026-03-18",
"2026-03-25"
],
"region": [
"West",
"South",
"North",
"West",
"South",
"East",
"North",
"West"
],
"product": [
"Laptop",
"Phone",
"Laptop",
"Monitor",
"Phone",
"Tablet",
"Laptop",
"Monitor"
],
"units": [
5, 10, 4, 8, 15, 7, 6, 9
],
"revenue": [
350000,
250000,
280000,
160000,
375000,
210000,
420000,
180000
],
"cost": [
280000,
190000,
220000,
125000,
285000,
165000,
330000,
140000
]
}
df = pd.DataFrame(data)
print(df)
print(df.head())
print(df.shape)
print(df.columns)
print(df.info())
print(df.describe())
The first inspection helps determine the number of rows, columns, data types, missing values and numerical ranges.
Data quality problems are common in professional environments. Typical issues include missing values, duplicates, incorrect data types and inconsistent categories.
import pandas as pd
df["date"] = pd.to_datetime(df["date"])
df = df.drop_duplicates()
df["region"] = df["region"].str.strip()
df["product"] = df["product"].str.strip()
df["units"] = pd.to_numeric(
df["units"],
errors="coerce"
)
df["revenue"] = pd.to_numeric(
df["revenue"],
errors="coerce"
)
df["cost"] = pd.to_numeric(
df["cost"],
errors="coerce"
)
print(df.isnull().sum())
Raw columns often need to be transformed into business metrics.
df["profit"] = (
df["revenue"] - df["cost"]
)
df["profit_margin"] = (
df["profit"] / df["revenue"] * 100
)
df["revenue_per_unit"] = (
df["revenue"] / df["units"]
)
print(
df[
[
"revenue",
"cost",
"profit",
"profit_margin",
"revenue_per_unit"
]
]
)
Suppose a sales manager wants a quick executive summary of the current dataset.
total_revenue = df["revenue"].sum()
total_cost = df["cost"].sum()
total_profit = df["profit"].sum()
total_units = df["units"].sum()
profit_margin = (
total_profit / total_revenue * 100
)
print(f"Revenue: ₹{total_revenue:,.0f}")
print(f"Cost: ₹{total_cost:,.0f}")
print(f"Profit: ₹{total_profit:,.0f}")
print(f"Units: {total_units:,}")
print(f"Margin: {profit_margin:.2f}%")
Grouping allows analysts to answer questions such as: "How much revenue did each region generate?"
regional_sales = (
df.groupby("region")
.agg(
revenue=("revenue", "sum"),
profit=("profit", "sum"),
units=("units", "sum")
)
.sort_values(
"revenue",
ascending=False
)
)
print(regional_sales)
product_analysis = (
df.groupby("product")
.agg(
revenue=("revenue", "sum"),
cost=("cost", "sum"),
profit=("profit", "sum"),
units=("units", "sum")
)
)
product_analysis["margin"] = (
product_analysis["profit"]
/ product_analysis["revenue"]
* 100
)
print(
product_analysis.sort_values(
"revenue",
ascending=False
)
)
top_transactions = (
df.sort_values(
"profit",
ascending=False
)
.head(5)
)
print(
top_transactions[
[
"date",
"product",
"region",
"revenue",
"profit"
]
]
)
Ranking is useful when management wants to identify high-value transactions, customers, products or sales representatives.
import numpy as np
revenue = df["revenue"]
print("Mean:", np.mean(revenue))
print("Median:", np.median(revenue))
print("Standard deviation:", np.std(revenue))
print("Minimum:", np.min(revenue))
print("Maximum:", np.max(revenue))
Time-series analysis helps organizations understand how a metric changes over days, weeks, months or years.
df["month"] = (
df["date"]
.dt.to_period("M")
)
monthly_revenue = (
df.groupby("month")["revenue"]
.sum()
)
print(monthly_revenue)
monthly_revenue = (
df.groupby("month")["revenue"]
.sum()
)
growth = (
monthly_revenue
.pct_change()
* 100
)
print(
growth.round(2)
)
Growth percentages help management identify acceleration, decline and seasonal patterns.
missing = df.isnull().sum()
missing_percentage = (
df.isnull().mean() * 100
)
quality_report = pd.DataFrame({
"missing_count": missing,
"missing_percentage":
missing_percentage
})
print(quality_report)
Missing data should be handled according to the meaning of the field. Possible approaches include removing records, filling values, using business defaults or investigating the source system.
Outliers are observations that differ substantially from the rest of the dataset. They may represent valid exceptional transactions or data-quality problems.
q1 = df["revenue"].quantile(0.25)
q3 = df["revenue"].quantile(0.75)
iqr = q3 - q1
lower = q1 - 1.5 * iqr
upper = q3 + 1.5 * iqr
outliers = df[
(df["revenue"] < lower) |
(df["revenue"] > upper)
]
print(outliers)
Correlation can help analysts explore whether numerical variables move together. It does not by itself establish causation.
numeric_columns = [
"units",
"revenue",
"cost",
"profit"
]
correlation = (
df[numeric_columns]
.corr()
)
print(
correlation.round(2)
)
import matplotlib.pyplot as plt
regional_sales = (
df.groupby("region")["revenue"]
.sum()
.sort_values(
ascending=False
)
)
regional_sales.plot(
kind="bar",
figsize=(9, 5)
)
plt.title("Revenue by Region")
plt.xlabel("Region")
plt.ylabel("Revenue")
plt.tight_layout()
plt.show()
Visualization helps communicate trends and comparisons more effectively than raw tables alone.
Imagine an e-commerce company wants to identify its highest-value customers.
customer_data = pd.DataFrame({
"customer": [
"C001",
"C002",
"C003",
"C004",
"C005",
"C006"
],
"orders": [
12, 5, 9, 3, 15, 7
],
"revenue": [
480000,
125000,
315000,
70000,
620000,
210000
]
})
customer_data["avg_order_value"] = (
customer_data["revenue"]
/ customer_data["orders"]
)
top_customers = (
customer_data
.sort_values(
"revenue",
ascending=False
)
)
print(top_customers)
A sales leader can combine revenue, profit and volume to understand performance more deeply.
sales_kpis = (
df.groupby("region")
.agg(
revenue=("revenue", "sum"),
profit=("profit", "sum"),
units=("units", "sum")
)
)
sales_kpis["margin"] = (
sales_kpis["profit"]
/ sales_kpis["revenue"]
* 100
)
sales_kpis["revenue_per_unit"] = (
sales_kpis["revenue"]
/ sales_kpis["units"]
)
print(
sales_kpis.round(2)
)
quality_report = pd.DataFrame({
"column": df.columns,
"data_type": [
str(df[col].dtype)
for col in df.columns
],
"missing_values": [
df[col].isnull().sum()
for col in df.columns
],
"unique_values": [
df[col].nunique()
for col in df.columns
]
})
print(quality_report)
Data-quality reporting can become an automated step in production data pipelines.
Analysis becomes valuable when numerical results are translated into clear business questions and evidence.
import pandas as pd
def analyze_sales(data):
df = pd.DataFrame(data)
# -----------------------------
# 1. Data preparation
# -----------------------------
df["date"] = pd.to_datetime(
df["date"]
)
df = df.drop_duplicates()
# -----------------------------
# 2. Business metrics
# -----------------------------
df["profit"] = (
df["revenue"]
- df["cost"]
)
df["margin"] = (
df["profit"]
/ df["revenue"]
* 100
)
# -----------------------------
# 3. Executive KPIs
# -----------------------------
total_revenue = df["revenue"].sum()
total_profit = df["profit"].sum()
total_units = df["units"].sum()
margin = (
total_profit
/ total_revenue
* 100
)
# -----------------------------
# 4. Regional analysis
# -----------------------------
regional = (
df.groupby("region")
.agg(
revenue=("revenue", "sum"),
profit=("profit", "sum"),
units=("units", "sum")
)
.sort_values(
"revenue",
ascending=False
)
)
# -----------------------------
# 5. Product analysis
# -----------------------------
products = (
df.groupby("product")
.agg(
revenue=("revenue", "sum"),
profit=("profit", "sum"),
units=("units", "sum")
)
.sort_values(
"revenue",
ascending=False
)
)
return {
"data": df,
"revenue": total_revenue,
"profit": total_profit,
"units": total_units,
"margin": margin,
"regional": regional,
"products": products
}
result = analyze_sales(data)
print(
f"Revenue: ₹{result['revenue']:,.0f}"
)
print(
f"Profit: ₹{result['profit']:,.0f}"
)
print(
f"Units: {result['units']}"
)
print(
f"Margin: {result['margin']:.2f}%"
)
print("\nRegional Analysis")
print(result["regional"])
print("\nProduct Analysis")
print(result["products"])
data_analysis_project/
│
├── data/
│ ├── raw/
│ │ └── sales.csv
│ │
│ └── processed/
│ └── cleaned_sales.csv
│
├── notebooks/
│ ├── 01_data_exploration.ipynb
│ ├── 02_data_cleaning.ipynb
│ └── 03_business_analysis.ipynb
│
├── src/
│ ├── data_loader.py
│ ├── cleaning.py
│ ├── metrics.py
│ ├── analysis.py
│ └── visualization.py
│
├── reports/
│ └── sales_report.html
│
├── tests/
│ └── test_analysis.py
│
├── requirements.txt
└── README.md
Separating raw data, processing logic, analysis notebooks, reports and tests makes the project easier to maintain.
def calculate_revenue(df):
return df["revenue"].sum()
def calculate_profit(df):
return (
df["revenue"] - df["cost"]
).sum()
def calculate_margin(df):
revenue = calculate_revenue(df)
profit = calculate_profit(df)
if revenue == 0:
return 0
return profit / revenue * 100
def calculate_units(df):
return df["units"].sum()
print(
"Revenue:",
calculate_revenue(df)
)
print(
"Profit:",
calculate_profit(df)
)
print(
"Margin:",
calculate_margin(df)
)
print(
"Units:",
calculate_units(df)
)
import unittest
import pandas as pd
def calculate_profit(df):
return (
df["revenue"]
- df["cost"]
).sum()
class TestSalesAnalysis(unittest.TestCase):
def setUp(self):
self.df = pd.DataFrame({
"revenue": [100, 200],
"cost": [60, 100]
})
def test_profit(self):
result = calculate_profit(
self.df
)
self.assertEqual(
result,
140
)
if __name__ == "__main__":
unittest.main()
- Starting analysis before understanding the data
- Ignoring missing values
- Deleting outliers without investigation
- Using incorrect data types
- Confusing correlation with causation
- Using averages without checking distributions
- Ignoring duplicate records
- Creating charts without a clear analytical question
- Mixing raw and processed datasets
- Failing to document assumptions
- Reporting metrics without defining their formulas
A professional data-analysis project is not simply about calculating averages or creating charts. The real value comes from connecting reliable data preparation with meaningful business questions.
The workflow demonstrated here can be extended into sales dashboards, customer analytics, financial reporting, marketing analysis, operations monitoring and automated executive reports.
The key professional lesson is to transform raw data into validated information, information into insights, and insights into measurable decisions.
Data Analysis Project for Professionals
Collect → Clean → Analyze → Visualize → Explain → Decide