Series — Column တစ်ခုလို data structure
Series သည် Pandas ရဲ့ one-dimensional data structure ဖြစ်ပြီး list တစ်ခုနဲ့ ဆင်တူပါတယ်။ ဒါပေမယ့် Series မှာ value တွေတင်မကဘဲ index လို့ခေါ်တဲ့ label တွေလည်း ပါပါတယ်။ Product price list, score list, temperature list စတဲ့ data တစ်ကြောင်းတည်းကို သိမ်းချင်ရင် Series သုံးနိုင်ပါတယ်။
python
import pandas as pd
prices = pd.Series([1500, 2500, 3200, 1800], name="Price")
print(prices)
print("Average price:", prices.mean())ဒီ code မှာ list ထဲက number တွေကို Series အဖြစ်ပြောင်းထားပါတယ်။ name="Price" က Series ရဲ့ label ဖြစ်ပြီး report ထုတ်တဲ့အခါ နားလည်လွယ်စေပါတယ်။ prices.mean() က average price ကိုတွက်ပေးပါတယ်။
You should see
0 1500 1 2500 2 3200 3 1800 Name: Price, dtype: int64 Average price: 2250.0Info
- ဘယ်ဘက်က 0, 1, 2, 3 တွေက index ဖြစ်ပါတယ်။
- ညာဘက်က 1500, 2500 စတာတွေက actual values ဖြစ်ပါတယ်။
- Series method တွေဖြစ်တဲ့
.sum(),.mean(),.max()တွေကို တိုက်ရိုက်သုံးနိုင်ပါတယ်။