簡體   English   中英

將數據框中的列轉換為字符串,導致數據不完整,增加字符串的長度

[英]Converting a column in Dataframe to string resulting in incomplete data, Increase the length of string

數據框“ A”列中的數據

'45-54 on Treatment for less than 1 month (Patient) '
'Ocetech| 65-74 Male  on Treatment for 10 years or more (Patient) '
'What is this?  Don't know screen name | 65-74 Female  on Treatment for 6 months to less than 1 year (Patient) '

將列“ A”轉換為字符串

c2 = c1.to_string(columns = ['A'])

將其轉換並存儲到c2后,行中的文本不完整,一半的文本未顯示。

電流輸出:

'45-54 on Treatment for less than 1 ...
'Ocetech| 65-74 Male  on Treatment f...
'What is this?  Don't know scree...

我試圖通過使用增加字符串的長度

c2 = c1['A'].astype('|S80')

但它顯示錯誤,

SystemError: <class 'UnicodeEncodeError'> returned a result with an error set

我建議使用此:

pd.options.display.max_colwidth = 1000

但是,如果那行不通,請嘗試在加載它們時確保所有字符串均為utf-8。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM