1
我有一個有兩列的熊貓數據框 - 一個用於id和其他相應的標題。我正在爲一些項目ID子集數據框並顯示結果數據框。在這樣做的情況下,項目ID會顯示正常,但相應的標題會被截斷並在幾個字符後以...
結尾,如何讓大熊貓在標題欄中顯示全文?大熊貓打印完整的字符串
我有一個有兩列的熊貓數據框 - 一個用於id和其他相應的標題。我正在爲一些項目ID子集數據框並顯示結果數據框。在這樣做的情況下,項目ID會顯示正常,但相應的標題會被截斷並在幾個字符後以...
結尾,如何讓大熊貓在標題欄中顯示全文?大熊貓打印完整的字符串
您可以使用display.max_colwidth
:在
df = pd.DataFrame(np.array([[1,'aaa'],
[2, 'long string long string long string long string long string']]), columns=['id','title'])
print (df)
id title
0 1 aaa
1 2 long string long string long string long strin...
#temporaly display long text
with pd.option_context('display.max_colwidth', 100):
print (df)
id title
0 1 aaa
1 2 long string long string long string long string long string
檢查'display.max_colwidth' [文件](http://pandas.pydata.org/pandas-docs/ stable/options.html#frequently-used-options)('In [44]:') – jezrael
@EdChum不完全是我想的。這個問題是當OP有多個列時,熊貓決定在打印時省略其中的一些。在我的情況下,只有兩列正在打印,但有一個被截斷 –
,那麼這是更合適的http://stackoverflow.com/questions/26277757/pandas-to-html-truncates-string-contents/26301947#26301947 – EdChum