Pandas- ကော်လံအကျယ်ကို ဘယ်လိုသတ်မှတ်မလဲ။


ပုံမှန်အားဖြင့်၊ Jupyter မှတ်စုစာအုပ်များသည် pandas DataFrame ရှိ ကော်လံများအတွက် အမြင့်ဆုံးအကျယ် 50 ကိုသာ ပြသသည်။

သို့သော်၊ သင်သည် အောက်ပါအစီအမံကို အသုံးပြု၍ DataFrame ကော်လံတစ်ခုစီ၏ အကျယ်ကို ပြရန် မှတ်စုစာအုပ်အား တွန်းအားပေးနိုင်ပါသည်။

 p.d. set_option (' display.max_colwidth ', None )

၎င်းသည် Jupyter မှတ်စုစာအုပ်စက်ရှင်တစ်ခုလုံးအတွက် အများဆုံးကော်လံအကျယ်တန်ဖိုးကို သတ်မှတ်ပေးမည်ဖြစ်သည်။

ကော်လံအကျယ်တစ်ခုလုံးကို ယာယီသာပြသလိုပါက၊ အောက်ပါ syntax ကို အသုံးပြုနိုင်ပါသည်။

 from pandas import option_context

with option_context(' display.max_colwidth ', None ):
    print (df)

နောက်ဆုံးတွင်၊ သင်သည် အောက်ပါ syntax ကို အသုံးပြု၍ Jupyter မှတ်စုစာအုပ်ရှိ မူရင်းကော်လံအကျယ်ဆက်တင်များကို ပြန်လည်သတ်မှတ်နိုင်သည်-

 p.d. reset_option (' display.max_colwidth ')

အောက်ဖော်ပြပါ ဥပမာသည် ဤလုပ်ဆောင်ချက်များကို လက်တွေ့အသုံးချနည်းကို ပြသထားသည်။

ဥပမာ- Pandas တွင် ကော်လံအကျယ်များကို သတ်မှတ်ခြင်း။

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

 import pandas as pd

#createDataFrame
df = pd. DataFrame ({' string_column ': ['A really really long string that contains lots of words', 'More words', 'Words', 'Cool words', 'Hey', 'Hi', 'Sup', 'Yo' ],
                   ' value_column ': [12, 15, 24, 24, 14, 19, 12, 38]})


#view DataFrame
print (df)

                                       string_column value_column
0 A really really long string that contains lots... 12
1 More words 15
2 Words 24
3 Cool words 24
4 Hey 14
5 Hello 19
6 Sup 12
7 Yo 38

ပုံမှန်အားဖြင့်၊ pandas သည် အကျယ် 50 သာရှိရန် string_column ကို ချုံ့သည်။

ကော်လံတစ်ခုလုံး၏ အကျယ်ကိုပြသရန်၊ သင်သည် အောက်ပါ syntax ကို သုံးနိုင်သည်-

 #specify no max value for the column width
p.d. set_option (' display.max_colwidth ', None )

#view DataFrame
print (df)

                                             string_column value_column
0 A really really long string that contains lots of words 12
1 More words 15
2 Words 24
3 Cool words 24
4 Hey 14
5 Hello 19
6 Sup 12
7 Yo 38

string_column မှ စာသားအားလုံးကို ယခုပြသထားကြောင်း သတိပြုပါ။

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

အများဆုံးကော်လံအကျယ်ကို ယာယီသာပြသရန်၊ ကျွန်ုပ်တို့သည် အောက်ပါ syntax ကို အသုံးပြုနိုင်ပါသည်။

 from pandas import option_context

with option_context(' display.max_colwidth ', None ):
    print (df)

                                             string_column value_column
0 A really really long string that contains lots of words 12
1 More words 15
2 Words 24
3 Cool words 24
4 Hey 14
5 Hello 19
6 Sup 12
7 Yo 38

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

 p.d. reset_option (' display.max_colwidth ')

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

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

Pandas DataFrame တွင် ကော်လံများအားလုံးကို ပြသနည်း
Pandas DataFrame တွင်အတန်းအားလုံးကိုပြသနည်း
Pandas- DataFrame မှ ဆဲလ်တန်ဖိုးကို မည်သို့ရယူရမည်နည်း။

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

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