Data Analytics project 05
Inventory Analysis Project with Python
Build a complete inventory analysis portfolio project with documented metrics, reproducible Python code, validation checks, and responsible interpretation.
Explore Data Analytics training in VizagView all project ideas
Business question
Which SKUs drive usage value, which need replenishment, and how quickly does current stock move?
Dataset and grain
One hundred fifty synthetic SKUs with annual unit demand, unit cost, on-hand units, lead time, and safety stock.
Requirements
Python 3.10 or later with numpy and pandas installed.
Method and validation checks
Rank annual usage value, assign ABC bands by cumulative value share, estimate daily demand and reorder point, and flag stock at or below that point.
- Cumulative value share finishes at one
- ABC uses value rather than unit count
- Zero stock produces a missing turnover proxy rather than infinity
- Reorder point includes lead-time demand plus safety stock
Complete Python code
Save the code as da_inventory_analysis.py. Review the stated model and field assumptions before using another dataset.
"""ABC inventory analysis with turnover and reorder flags."""
from __future__ import annotations
import numpy as np
import pandas as pd
def make_demo_inventory(n: int = 150, seed: int = 42) -> pd.DataFrame:
rng = np.random.default_rng(seed)
annual_units = rng.integers(20, 3000, n)
unit_cost = rng.uniform(80, 6500, n)
on_hand = rng.integers(0, 700, n)
lead_time = rng.integers(3, 46, n)
return pd.DataFrame({"sku": [f"SKU{i:04d}" for i in range(1, n + 1)], "annual_units_sold": annual_units,
"unit_cost": unit_cost.round(2), "on_hand_units": on_hand,
"lead_time_days": lead_time, "safety_stock_units": rng.integers(5, 100, n)})
def analyse_inventory(data: pd.DataFrame) -> pd.DataFrame:
inv = data.copy()
inv["annual_usage_value"] = inv["annual_units_sold"] * inv["unit_cost"]
inv = inv.sort_values("annual_usage_value", ascending=False).reset_index(drop=True)
inv["cumulative_value_share"] = inv["annual_usage_value"].cumsum() / inv["annual_usage_value"].sum()
inv["abc_class"] = np.select([inv["cumulative_value_share"] <= 0.80, inv["cumulative_value_share"] <= 0.95], ["A", "B"], default="C")
inv["daily_demand"] = inv["annual_units_sold"] / 365
inv["reorder_point"] = inv["daily_demand"] * inv["lead_time_days"] + inv["safety_stock_units"]
inv["reorder_flag"] = inv["on_hand_units"] <= inv["reorder_point"]
inv["inventory_turnover_proxy"] = inv["annual_units_sold"] / inv["on_hand_units"].replace(0, np.nan)
return inv
def main() -> None:
result = analyse_inventory(make_demo_inventory())
print(result.groupby("abc_class").agg(skus=("sku", "size"), value=("annual_usage_value", "sum"), reorder_rate=("reorder_flag", "mean")).round(3))
print("Reorder flags are planning examples; real policies need demand variability and service levels.")
if __name__ == "__main__":
main()
Build and run the project
Run python da_inventory_analysis.py to create ABC classes, reorder points, and a turnover proxy.
- Confirm the source grain and field definitions.
- Reconcile record counts and additive totals.
- Validate rate denominators and date filters.
- Review outliers and missing values.
- Read the interpretation limits before sharing conclusions.
Expected analytical output
SKU-level ABC class, cumulative value share, reorder point, reorder flag, and inventory-turnover proxy.
Interpretation and responsible-use limits
The reorder example assumes stable average demand and fixed lead time. Real policy needs demand and lead-time variability, service levels, order constraints, seasonality, and review by operations.
Ways to extend the project
Calculate EOQ, safety stock from variability, supplier performance, stockout cost, ageing, service level, and scenario-tested reorder policies.
Continue learning Data Analytics
Try the next project, return to the Softenant project library, or explore the Data Analytics course in Vizag for guided SQL, Excel, Power BI, Python, dashboard, and portfolio practice.