Pandas dataframe တွင် ကော်လံများကို လှည့်နည်း


Pandas DataFrame ကော်လံများမှတဆင့် ထပ်လောင်းဖော်ပြရန် အောက်ပါအခြေခံ syntax ကို သင်အသုံးပြုနိုင်သည်-

 for name, values in df. iteritems ():
  print (values)

အောက်ဖော်ပြပါနမူနာများသည် အောက်ပါ pandas DataFrame နှင့် လက်တွေ့တွင် ဤ syntax ကိုမည်သို့အသုံးပြုရမည်ကို ပြသသည် ။

 import pandas as pd

#createDataFrame
df = pd. DataFrame ({' points ': [25, 12, 15, 14, 19],
                   ' assists ': [5, 7, 7, 9, 12],
                   ' rebounds ': [11, 8, 10, 6, 6]})

#view DataFrame
df

	points assists rebounds
0 25 5 11
1 12 7 8
2 15 7 10
3 14 9 6
4 19 12 6

ဥပမာ 1- DataFrame ကော်လံအားလုံးအပေါ် ထပ်လုပ်ပါ။

အောက်ဖော်ပြပါ ကုဒ်သည် ပန်ဒါဒေတာဘောင်တစ်ခုစီ၏ ကော်လံတစ်ခုစီတွင် မည်သို့ပြန်ဆိုရမည်ကို ပြသသည်-

 for name, values in df. iteritems ():
print (values)

0 25
1 12
2 15
3 14
4 19
Name: points, dtype: int64
0 5
1 7
2 7
3 9
4 12
Name: assists, dtype: int64
0 11
1 8
2 10
3 6
4 6
Name: rebounds, dtype: int64

ကော်လံတစ်ခုစီကို လှည့်ပတ်ကာ ကော်လံအမည်များကိုသာ ပရင့်ထုတ်ရန် အောက်ပါ syntax ကို အသုံးပြုနိုင်သည်။

 for name, values in df. iteritems ():
print (name)

points
assists
rebounds

ဥပမာ 2- သီးခြားကော်လံများပေါ်တွင် ထပ်လောင်းပါ။

အောက်ပါ syntax သည် pandas DataFrame အတွင်းရှိ သီးခြားကော်လံများပေါ်တွင် ထပ်တလဲလဲလုပ်နည်းကို ပြသသည်-

 for name, values in df[[' points ', ' rebounds ']]. iteritems ():
  print (values)

0 25
1 12
2 15
3 14
4 19
Name: points, dtype: int64
0 11
1 8
2 10
3 6
4 6
Name: rebounds, dtype: int64

သတ်မှတ်ထားသော ကော်လံအကွာအဝေးတွင် ထပ်လောင်းဖော်ပြရန် အောက်ဖော်ပြပါ အထားအသိုကို အသုံးပြုနိုင်သည်။

 for name, values in df. iloc [:, 0:2] . iteritems ():
  print (values)

0 25
1 12
2 15
3 14
4 19
Name: points, dtype: int64
0 5
1 7
2 7
3 9
4 12
Name: assists, dtype: int64

iteritems() လုပ်ဆောင်ချက်အတွက် စာရွက်စာတမ်းအပြည့်အစုံကို ဤနေရာတွင် ရှာဖွေနိုင်ပါသည်။

ထပ်လောင်းအရင်းအမြစ်များ

Pandas ရှိ ရွေးချယ်ထားသော ကော်လံများတွင် လုပ်ဆောင်ချက်တစ်ခုကို မည်သို့အသုံးပြုရမည်နည်း။
Pandas တွင် ကော်လံအစီစဥ်ကို ပြောင်းလဲနည်း
Pandas ရှိ အညွှန်းအားဖြင့် ကော်လံများကို မည်ကဲ့သို့ ဖျက်မည်နည်း။

မှတ်ချက်တစ်ခုထည့်ပါ။

သင့် email လိပ်စာကို ဖော်ပြမည် မဟုတ်ပါ။ လိုအပ်သော ကွက်လပ်များကို * ဖြင့်မှတ်သားထားသည်