Thuta Learning
ရှာဖွေရန်
ProjectsData & Databasesintermediate

Mini Project: Sales Report

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Mini Project: Sales Report တစ်ခုတည်ဆောက်မယ်

ဒီ project မှာ small sales dataset တစ်ခုကို Pandas နဲ့ဖတ်ပြီး total sales တွက်မယ်၊ missing quantity ကိုဖြည့်မယ်၊ category အလိုက် sales summary ထုတ်မယ်၊ best-selling product ကိုရှာမယ်။ ဒါက real shop report, restaurant menu sales, online store order summary စတဲ့ project တွေအတွက် အခြေခံ flow တစ်ခုပါ။

python
import pandas as pd
import numpy as np

orders = pd.DataFrame({
    "OrderID": [101, 102, 103, 104, 105],
    "Category": ["Drink", "Drink", "Food", "Food", "Drink"],
    "Product": ["Tea", "Coffee", "Cake", "Noodle", "Tea"],
    "Price": [1200, 1800, 2500, 5000, 1200],
    "Qty": [3, 2, 1, np.nan, 2]
})

# 1. Check missing values
print("Missing values:")
print(orders.isna().sum())

# 2. Fill missing Qty with 0
orders["Qty"] = orders["Qty"].fillna(0)

# 3. Create Total column
orders["Total"] = orders["Price"] * orders["Qty"]

# 4. Summarize sales by category
category_report = orders.groupby("Category")["Total"].sum().sort_values(ascending=False)

# 5. Find best-selling product by total sales
product_report = orders.groupby("Product")["Total"].sum().sort_values(ascending=False)

print("
Clean Orders:")
print(orders)
print("
Category Report:")
print(category_report)
print("
Best-selling Product:")
print(product_report.head(1))

Project flow က data analysis အလုပ်တစ်ခုရဲ့ ပုံမှန်လမ်းကြောင်းပါ။ အရင်ဆုံး missing value စစ်တယ်၊ data ကို clean လုပ်တယ်၊ calculation column ထည့်တယ်၊ ပြီးရင် groupby() နဲ့ report ထုတ်ပါတယ်။ ဒီ pattern ကို data project အများစုမှာ ပြန်သုံးလို့ရပါတယ်။

You should see
Missing values: OrderID 0 Category 0 Product 0 Price 0 Qty 1 dtype: int64 Clean Orders: OrderID Category Product Price Qty Total 0 101 Drink Tea 1200 3.0 3600.0 1 102 Drink Coffee 1800 2.0 3600.0 2 103 Food Cake 2500 1.0 2500.0 3 104 Food Noodle 5000 0.0 0.0 4 105 Drink Tea 1200 2.0 2400.0 Category Report: Category Drink 9600.0 Food 2500.0 Name: Total, dtype: float64 Best-selling Product: Product Tea 6000.0 Name: Total, dtype: float64

လေ့ကျင့်ခန်း

နောက်ထပ်တိုးချဲ့ချင်ရင် CSV file မှ data ဖတ်အောင်ပြောင်းပါ၊ date column ထည့်ပြီး daily/monthly report ခွဲပါ၊ result ကို to_csv() နဲ့ export လုပ်ပါ။ Dashboard သို့မဟုတ် chart ထုတ်ချင်ရင် Matplotlib/Plotly နဲ့ ဆက်လေ့လာနိုင်ပါတယ်။

You'll know it worked when:

Mini Project: Sales Report | Thuta Learning