失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > python单元格内换行_Python Pandas可防止单元格中的换行符

python单元格内换行_Python Pandas可防止单元格中的换行符

时间:2021-05-25 23:08:21

相关推荐

python单元格内换行_Python Pandas可防止单元格中的换行符

使用以下函数,我已经设法防止在笔记本中的输出中截断:

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

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

但是,它仍会在某些单元格中打破长行(不是截断!).我怎么能阻止它呢?

(我不关心总表的宽度,因为我只需滚动笔记本单元格的输出……)

对我来说,[emailprotected]_option(‘display.expand_frame_repr’,False).

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)

如果觉得《python单元格内换行_Python Pandas可防止单元格中的换行符》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。