2016-08-03 89 views
2

使用以下功能换行符,我已经成功地防止截断,在我的笔记本上输出:Python的大熊猫防止细胞

pd.set_option('display.max_colwidth', 200) 
pd.set_option('display.max_columns', 0) 

但是,它仍然打破某些细胞内排长队(不截断!) 。我怎样才能防止它做到这一点?

(我不关心总表将有多宽的,因为我可以在笔记本电脑电池的输出只需滚动...)

+0

如果你通过'-1',那么你说没有限制,你仍然有一些超过200个字符的列? – EdChum

+0

对不起,没有显示所有文本,但在一个单元格内分成多行=( – Zelphir

+2

尝试'pd.set_option('display.expand_frame_repr',False)' – EdChum

回答

0

为我工作pandas.set_option('display.expand_frame_repr', False)通过@EdChum的建议。

import pandas 
matrix = [[None]*5]*4 
matrix[1][1] = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut" 
matrix[1][4] = matrix[1][1] 
print pandas.DataFrame(matrix) # will print the matrix, 
# column 4 is completely underneath the other 3 columns with all rows 


pandas.set_option('display.expand_frame_repr', False) 
print pandas.DataFrame(matrix) # prints only one table (no break of columns)