IPython Notebook 输出单元格正在截断我列表的内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23388810/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IPython Notebook output cell is truncating contents of my list
提问by user3006135
I have a long list (about 4000 items) whose content is suppressed when I try to display it in an ipython notebook output cell. Maybe two-thirds is shown, but the end has a "...]", rather than all the contents of the list. How do I get ipython notebook to display the whole list instead of a cutoff version?
我有一个很长的列表(大约 4000 个项目),当我尝试在 ipython 笔记本输出单元格中显示它时,其内容被抑制。也许显示了三分之二,但最后有一个“...]”,而不是列表的所有内容。如何让 ipython notebook 显示整个列表而不是截止版本?
回答by dmvianna
A quick hack if you're using pandas is to do
如果你使用熊猫,一个快速的黑客是做
from pandas import DataFrame
from IPython.display import HTML
HTML(DataFrame(myList).to_html())
回答by David Smith
Here's a way to display the whole list in the IPython output cell that doesn't require Pandas:
这是一种在不需要 Pandas 的 IPython 输出单元中显示整个列表的方法:
from IPython.display import HTML
x = range(4000)
HTML('<br />'.join(str(y) for y in x))
It is also pretty easy to add additional HTML elements and get a more elaborate display. Clicking to the left of the output cell will now shrink the contents and add a local scroll bar.
添加额外的 HTML 元素并获得更精细的显示也很容易。单击输出单元格的左侧现在将缩小内容并添加本地滚动条。
回答by Noah
This should work:
这应该有效:
print(str(mylist))
Simple!
简单的!
回答by impiyush
I know its a pretty old thread, but still wanted to post my answer in the hope it helps someone. You can change the number of max_seq_itemsshown by configuring the pandas options as follows:
我知道它是一个很旧的线程,但仍然想发布我的答案,希望它可以帮助某人。您可以通过配置 pandas 选项来更改显示的max_seq_items的数量,如下所示:
pd.options.display.max_seq_items = 2000
回答by Jelmer
pd.options.display.max_rows = 4000
worked for me
为我工作
See : http://pandas.pydata.org/pandas-docs/stable/options.html
请参阅:http: //pandas.pydata.org/pandas-docs/stable/options.html
回答by Saurabh Kumar Singh
just use the print command instead of calling the list directly. Like print mylist . It would not truncate then.
只需使用打印命令而不是直接调用列表。喜欢打印 mylist 。那时它不会截断。
回答by Alaleh Rz
The following line prints everything in your list in a readable manner.
以下行以可读的方式打印列表中的所有内容。
[print(x) for x in lis]
回答by Imre Kerr
How to disable list truncation in IPython:
如何在 IPython 中禁用列表截断:
- Create an IPython config file if you don't already have one:
ipython profile create
- Edit the config file to include this line:
c.PlainTextFormatter.max_seq_length = 0
- Restart your notebook instance.
- 如果您还没有 IPython 配置文件,请创建一个:
ipython profile create
- 编辑配置文件以包含以下行:
c.PlainTextFormatter.max_seq_length = 0
- 重启你的笔记本实例。