0

I am working on the Jupyter notebook and have been facing issues in increasing the length of the output of the Jupyter Notebook. I can see the output as follows:enter image description here

I tried increasing the default length of the columns in pandas with no success. Can you please help me with it?

Mufeez
  • 55
  • 5
  • What you show doesn't look like up to date Jupyter rendering a dataframe. You should be seeing something like at the top of [here](https://stackoverflow.com/q/56384952/8508004) by default. Maybe you altered settings or how Pandas redners? It should be using the [pandas.DataFrame.to_html()](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_html.html) representation. And that representation can be even styled in some fancier ways on top of that, see [Table Visualization](https://pandas.pydata.org/docs/user_guide/style.html). – Wayne Feb 02 '23 at 21:09
  • I think those were the default settings I had on my Jupyter. I used this pd.set_option('display.expand_frame_repr', False) to expand my output to Notebook area. But this one had other problems.. – Mufeez Feb 03 '23 at 08:06
  • I will try your solutions and let you know.. I think it should work – Mufeez Feb 03 '23 at 08:06
  • That those were "settings I had on my Jupyter" makes sense. I figured you had tried adjusting some stuff. It's just they weren't typical, and so I didn't want to assume in case there was something I was missing. Note there are other viewers that you can plug into as well. Such a thing may not be necessary now for you but may suit other cases. – Wayne Feb 03 '23 at 16:08

1 Answers1

0

If you were using the typical way to view a dataframe in Jupyter (see my puzzelment about your screenshot in my comments to your original post) it would be things like this:

with pd.option_context('display.max_rows', None, 'display.max_columns', None):
    display(df)

(Note that will work with the text-based viewing, too. Note it uses print(df) in the answer to 'Pretty-print an entire Pandas Series / DataFrame'.

with pd.option_context('display.max_rows', None, 'display.max_columns', None,'display.max_colwidth', -1):
    display(df)

(If you prefer text like you posted, replace display() with print()

Generally with the solutions above the view window in Jupyter will get scrollbars so you can navigate to view all still.

You can also set the number of rows to show to be lower to save space, see example here.

You may also be interested in Pandas dataframe hide index functionality? or Using python / Jupyter Notebook, how to prevent row numbers from printing?.

As pointed out here, setting some some global options is covered in the Pandas Documentation for top-level options.


For display() to work these days you don't need to do anything extra. But if your are using old Jupyter or it doesn't work then try adding towards the top of your notebook file and running the following as a cell first:

from IPython.display import display
Wayne
  • 6,607
  • 8
  • 36
  • 93
  • I tried this and it is generating the same output that I have uploaded in the question – Mufeez Feb 06 '23 at 08:20
  • Specifically what did you try and why not show some examples in your post by updating? I supplied three suggestions and global ones, too. These options should be working if things are normal with the underlying software. Remember, your dataframe shouldn't be showing like you show in your post in the first place. This is consistent with something underlying being a problem. You suggested that wasn't the case in your comments but it is consistente. It's hard to help if you aren't sharing more information. Also, asking for that many rows is out of hand. There's specific solutions for working ... – Wayne Feb 06 '23 at 13:35
  • with dataframes that large. Can you make a new environment where the normal display works and then try solutions with more reasonably sized dataframes? You don't need more than 100 to be able to test this from default settings. (Also don't share code as text. It makes it easier for people to try your examples and share what they see.) – Wayne Feb 06 '23 at 13:36