Condition ဖြင့် data စစ်ထုတ်ခြင်း
Condition selection ဆိုတာလိုချင်တဲ့ rows တွေကို စည်းကမ်းတစ်ခုနဲ့ filter လုပ်တာပါ။ SQL မှာ WHERE သုံးသလို Pandas မှာ df[df["Column"] condition] ပုံစံနဲ့ သုံးပါတယ်။
python
import pandas as pd
df = pd.DataFrame({
"Name": ["Alice", "Bob", "Charlie", "Daisy"],
"Age": [25, 30, 35, 22],
"Score": [82, 91, 76, 95]
})
high_scores = df[df["Score"] >= 90]
adults = df[df["Age"] >= 30]
print("High scores:")
print(high_scores)
print("
Age 30 and above:")
print(adults)df["Score"] >= 90 က True/False list တစ်ခုထုတ်ပါတယ်။ Pandas က True ဖြစ်တဲ့ rows တွေကိုပဲရွေးပြီး DataFrame အသစ်ပြန်ပေးပါတယ်။ ဒါကြောင့် report ထုတ်တာ၊ customer segment ခွဲတာ၊ sales threshold စစ်တာတွေမှာ အသုံးများပါတယ်။
You should see
High scores: Name Age Score 1 Bob 30 91 3 Daisy 22 95 Age 30 and above: Name Age Score 1 Bob 30 91 2 Charlie 35 76Info
Condition တစ်ခုထက်ပိုသုံးချင်ရင် & နှင့် | ကိုသုံးပြီး condition တစ်ခုချင်းစီကို parentheses နဲ့ခွဲရေးပါ။ ဥပမာ df[(df["Age"] >= 30) & (df["Score"] >= 80)]