Pandas ရှိ ဂဏန်းကော်လံများကိုသာ ရွေးချယ်နည်း
Pandas DataFrame အတွင်းရှိ ဂဏန်းကော်လံများကိုသာ ရွေးချယ်ရန် အောက်ပါ အခြေခံ အထားအသိုကို အသုံးပြုနိုင်ပါသည်။
import pandas as pd import numpy as np df. select_dtypes (include= np.number )
အောက်ဖော်ပြပါ ဥပမာသည် ဤလုပ်ဆောင်ချက်ကို လက်တွေ့အသုံးချနည်းကို ပြသထားသည်။
ဥပမာ- Pandas ရှိ ဂဏန်းကော်လံများကိုသာ ရွေးပါ။
အမျိုးမျိုးသော ဘတ်စကတ်ဘောကစားသမားများအကြောင်း အချက်အလက်ပါရှိသော အောက်ပါပန်ဒါ DataFrame ရှိသည်ဆိုပါစို့။
import pandas as pd #createDataFrame df = pd. DataFrame ({' team ': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'], ' points ': [18, 22, 19, 14, 14, 11, 20, 28], ' assists ': [5, 7, 7, 9, 12, 9, 9, 4], ' rebounds ': [11, 8, 10, 6, 6, 5, 9, 12]}) #view DataFrame print (df) team points assists rebounds 0 A 18 5 11 1 B 22 7 8 2 C 19 7 10 3 D 14 9 6 4 E 14 12 6 5 F 11 9 5 6 G 20 9 9 7:28 4 12
DataFrame မှ ဂဏန်းကော်လံများကိုသာ ရွေးရန် အောက်ပါ syntax ကို အသုံးပြုနိုင်ပါသည်။
import numpy as np
#select only the numeric columns in the DataFrame
df. select_dtypes (include= np.number )
points assists rebounds
0 18 5 11
1 22 7 8
2 19 7 10
3 14 9 6
4 14 12 6
5 11 9 5
6 20 9 9
7 28 4 12
ဂဏန်းကော်လံ သုံးခုကိုသာ ရွေးချယ်ထားသည် – အမှတ်များ ၊ ကူညီပေးခြင်း နှင့် ပြန်ခုန်ခြင်းများကို သတိပြုပါ။
DataFrame အတွင်းရှိ variable တစ်ခုစီ၏ ဒေတာအမျိုးအစားကိုပြသရန် dtypes() လုပ်ဆောင်ချက်ကို အသုံးပြုခြင်းဖြင့် ဤကော်လံများသည် ဂဏန်းများဖြစ်ကြောင်း အတည်ပြုနိုင်သည်-
#display data type of each variable in DataFrame
df. dtypes
team object
int64 dots
assists int64
rebounds int64
dtype:object
ရလဒ်အရ အသင်းသည် အရာဝတ္ထုတစ်ခု (ဆိုလိုသည်မှာ ကြိုးတစ်ချောင်း) ဖြစ်ပြီး အမှတ်များ ၊ assists နှင့် rebounds များ အားလုံးသည် ကိန်းဂဏာန်းများဖြစ်သည် ။
DataFrame ၏ ဂဏန်းကော်လံများစာရင်းကို ရယူရန် အောက်ပါကုဒ်ကိုလည်း အသုံးပြုနိုင်ကြောင်း သတိပြုပါ။
#display list of numeric variables in DataFrame
df. select_dtypes (include=np. number ). columns . tolist ()
['points', 'assists', 'rebounds']
၎င်းသည် ကျွန်ုပ်တို့အား ၎င်းတို့၏ အမှန်တကယ်တန်ဖိုးများကို မမြင်ဘဲ DataFrame ရှိ ကိန်းဂဏာန်းကိန်းရှင်များ၏ အမည်များကို လျင်မြန်စွာမြင်နိုင်စေပါသည်။
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် ပန်ဒါများတွင် အခြားဘုံအလုပ်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
Pandas တွင် နာမည်ဖြင့် ကော်လံများကို မည်သို့ရွေးချယ်ရမည်နည်း။
Pandas ရှိ အညွှန်းအလိုက် ကော်လံများကို မည်သို့ရွေးချယ်ရမည်နည်း။
Pandas တွင် သီးခြားစာကြောင်းတစ်ခုပါရှိသော ကော်လံများကို မည်သို့ရွေးချယ်ရမည်နည်း။