IPython Notebook output cell is truncating contents of my list

后端 未结 9 1588
轮回少年
轮回少年 2020-12-01 11:29

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

相关标签:
9条回答
  • 2020-12-01 12:09

    How to disable list truncation in IPython:

    1. Create an IPython config file if you don't already have one:
      ipython profile create
      
    2. Edit the config file to include this line:
      c.PlainTextFormatter.max_seq_length = 0
      
    3. Restart your notebook instance.
    0 讨论(0)
  • 2020-12-01 12:17

    Here's a way to display the whole list in the IPython output cell that doesn't require Pandas:

    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.

    0 讨论(0)
  • 2020-12-01 12:19

    The following line prints everything in your list in a readable manner.

    [print(x) for x in lis] 
    
    0 讨论(0)
  • 2020-12-01 12:19

    For cases where the output of print(mylist) is something like [1, 1, 1, ..., 1, 1, 1] then [*mylist] will expand the items into rows where all items are visible.

    0 讨论(0)
  • 2020-12-01 12:20

    This should work:

    print(str(mylist))
    

    Simple!

    0 讨论(0)
  • 2020-12-01 12:21

    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_items shown by configuring the pandas options as follows:

    pd.options.display.max_seq_items = 2000
    
    0 讨论(0)
提交回复
热议问题