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

Operations & Stats

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

Operations နှင့် Basic Statistics

Pandas မှာ column တစ်ခုတည်းပေါ်မှာ sum, average, min, max စတဲ့ calculation တွေကို လွယ်လွယ်ကူကူတွက်နိုင်ပါတယ်။ Sales report, student score report, expense tracker, inventory value တွက်တာတွေမှာ အလွန်အသုံးဝင်ပါတယ်။

python
import pandas as pd

df = pd.DataFrame({
    "Product": ["Tea", "Coffee", "Cake"],
    "Price": [1200, 1800, 2500],
    "Qty": [3, 2, 1]
})

df["Total"] = df["Price"] * df["Qty"]

print(df)
print("
Total Sales:", df["Total"].sum())
print("Average Order Value:", df["Total"].mean())
print("Highest Sale:", df["Total"].max())

df["Total"] = df["Price"] * df["Qty"] က column နှစ်ခုကို row အလိုက်မြှောက်ပြီး column အသစ်တစ်ခုထည့်တာပါ။ Pandas က loop မရေးရဘဲ column-level operation ကို တစ်ကြောင်းတည်းနဲ့လုပ်ပေးနိုင်ပါတယ်။

You should see
Product Price Qty Total 0 Tea 1200 3 3600 1 Coffee 1800 2 3600 2 Cake 2500 1 2500 Total Sales: 9700 Average Order Value: 3233.3333333333335 Highest Sale: 3600

Info

Column တွေ number type ဖြစ်ရပါမယ်။ Price ထဲမှာ "1,200" လို comma ပါတဲ့ text ဖြစ်နေရင် calculation မလုပ်ခင် number အဖြစ်ပြောင်းဖို့လိုပါတယ်။

Operations & Stats | Thuta Learning