Pandas- describe() ကို အသုံးပြုနည်းနှင့် သိပ္ပံဆိုင်ရာ အမှတ်အသားများကို ဖယ်ရှားနည်း
pandas DataFrame အတွင်းရှိ variable များအတွက် descriptive statistics ကို ဖန်တီးရန် describe() လုပ်ဆောင်ချက်ကို သင်အသုံးပြုနိုင်ပါသည်။
describe() လုပ်ဆောင်ချက်၏ output မှ သိပ္ပံဆိုင်ရာ အမှတ်အသားများကို ဖယ်ရှားရန်၊ သင်သည် အောက်ပါနည်းလမ်းများကို အသုံးပြုနိုင်ပါသည်။
နည်းလမ်း 1- ကော်လံတစ်ခုဖြင့် describe() ကိုအသုံးပြုသောအခါ သိပ္ပံဆိုင်ရာအမှတ်အသားများကို ဖယ်ရှားပါ။
df[' my_column ']. describe (). apply ( lambda x: format (x, ' f '))
နည်းလမ်း 2- ကော်လံများစွာဖြင့် describe() ကိုအသုံးပြုသည့်အခါ သိပ္ပံဆိုင်ရာအမှတ်အသားများကို ဖယ်ရှားပါ။
df. describe (). apply ( lambda x: x.apply (' {0:.5f} '. format ))
အောက်ဖော်ပြပါနမူနာများသည် အောက်ပါ pandas DataFrame ဖြင့် လက်တွေ့တွင် နည်းလမ်းတစ်ခုစီကို အသုံးပြုနည်းကို ပြသသည်-
import pandas as pd
#createDataFrame
df = pd. DataFrame ({' store ': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B'],
' sales ': [8450550, 406530, 53000, 6000, 2000, 4000, 5400, 6500],
' returns ':[2212200, 145200, 300, 2500, 700, 600, 800, 1200]})
#view DataFrame
print (df)
store sales returns
0 A 8450550 2212200
1 A 406530 145200
2 A 53000 300
3 A 6000 2500
4 B 2000 700
5 B 4000 600
6 B 5400 800
7 B 6500 1200
ဥပမာ 1- ကော်လံတစ်ခုဖြင့် describe() ကိုအသုံးပြုသည့်အခါ သိပ္ပံဆိုင်ရာအမှတ်အသားများကို ဖယ်ရှားပါ။
အရောင်း ကော်လံအတွက် သရုပ်ဖော်ကိန်းဂဏန်းများကို တွက်ချက်ရန် describe() လုပ်ဆောင်ချက်ကို အသုံးပြုပါက၊ အထွက်တန်ဖိုးများကို သိပ္ပံနည်းကျ အမှတ်အသားဖြင့် ပြသပါမည်-
#calculate descriptive statistics for sales column
df[' sales ']. describe ()
count 8.000000e+00
mean 1.116748e+06
std 2.966552e+06
min 2.000000e+03
25% 5.050000e+03
50% 6.250000e+03
75% 1.413825e+05
max 8.450550e+06
Name: sales, dtype: float64
အထွက်တန်ဖိုးတစ်ခုစီကို သိပ္ပံနည်းကျအမှတ်အသားဖြင့် ပြသသည်ကို သတိပြုပါ။
သိပ္ပံနည်းကျ မှတ်ချက်များကို အထွက်မှ ဖယ်ရှားရန် အောက်ပါ syntax ကို ကျွန်ုပ်တို့ အသုံးပြုနိုင်ပါသည်။
#calculate descriptive statistics for sales column and suppress scientific notation
df[' sales ']. describe (). apply ( lambda x: format (x, ' f '))
count 8.000000
mean 1116747.500000
std 2966551.594104
min 2000.000000
25% 5050.000000
50% 6250.000000
75% 141382.500000
max 8450550.000000
Name: sales, dtype: object
output မှတန်ဖိုးများကိုယခုသိပ္ပံနည်းကျအမှတ်အသားမပါဘဲပြသသည်ကိုသတိပြုပါ။
ဥပမာ 2- ကော်လံများစွာဖြင့် describe() ကိုအသုံးပြုသောအခါ သိပ္ပံဆိုင်ရာအမှတ်အသားများကို ဖယ်ရှားပါ။
ကိန်းဂဏာန်းကော်လံတစ်ခုစီအတွက် သရုပ်ဖော်ကိန်းဂဏန်းများကို တွက်ချက်ရန် describe() လုပ်ဆောင်ချက်ကို အသုံးပြုပါက၊ အထွက်တန်ဖိုးများကို သိပ္ပံနည်းကျအမှတ်အသားဖြင့် ပြသပါမည်-
#calculate descriptive statistics for each numeric column
df. describe ()
sales returns
count 8.000000e+00 8.000000e+00
mean 1.116748e+06 2.954375e+05
std 2.966552e+06 7.761309e+05
min 2.000000e+03 3.000000e+02
25% 5.050000e+03 6.750000e+02
50% 6.250000e+03 1.000000e+03
75% 1.413825e+05 3.817500e+04
max 8.450550e+06 2.212200e+06
အထွက်တန်ဖိုးတစ်ခုစီကို သိပ္ပံနည်းကျအမှတ်အသားဖြင့် ပြသသည်ကို သတိပြုပါ။
သိပ္ပံနည်းကျ မှတ်ချက်များကို အထွက်မှ ဖယ်ရှားရန် အောက်ပါ syntax ကို အသုံးပြုနိုင်ပါသည်။
#calculate descriptive statistics for numerical columns and suppress scientific notation
df. describe (). apply ( lambda x: x.apply (' {0:.5f} '. format ))
sales returns
count 8.00000 8.00000
mean 1116747.50000 295437.50000
std 2966551.59410 776130.93692
min 2000.00000 300.00000
25% 5050.00000 675.00000
50% 6250.00000 1000.00000
75% 141382.50000 38175.00000
max 8450550.00000 2212200.00000
output မှတန်ဖိုးများကိုယခုသိပ္ပံနည်းကျအမှတ်အသားမပါဘဲပြသသည်ကိုသတိပြုပါ။
ဤဥပမာတွင် ကျွန်ုပ်တို့သည် အထွက်တွင် ဒဿမ ၅ နေရာပြသရန် 0:.5f ကို အသုံးပြုထားကြောင်း သတိပြုပါ။
မတူညီသောဒဿမနေရာများကိုပြသရန် 5 ကို မတူညီသောနံပါတ်ဖြင့် အစားထိုးရန် အားမနာပါ။
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် ပန်ဒါများတွင် အခြားဘုံလုပ်ဆောင်ချက်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
Pandas- အုပ်စုတစ်ခုစီအတွက် စုဆောင်းငွေကို တွက်ချက်နည်း
Pandas- အုပ်စုအလိုက် ထူးခြားသောတန်ဖိုးများကို ရေတွက်နည်း
Pandas- အုပ်စုအလိုက် ဆက်စပ်မှုကို တွက်ချက်နည်း