How to make pandas show the entire dataframe without cropping it by columns?

Viewed 993

I am trying to represent cubic spline interpolation information for function f(x) as a dataframe. When trying to print into a spyder, I find that the columns are being cut off. When trying to reproduce the output in Jupiter Lab, I got the same thing. screenshot When I ran in ipython via terminal I got the desired full dataframe output. I searched the integnet and tried the pandas commands setting options pd.set_options(), but nothing came of it.

I attach a screenshot with the output in ipython.

3 Answers

In Juputer can use:

from IPython.display import display, HTML

and instead of

print(dataframe)

use of in anyway place

display(HTML(dataframe.to_html()))

This will create a nice table. enter image description here

Unfortunately, this will not work in the spyder. So you can try to adjust the width of the ipython were suggested. But in most cases this will make the output poorly or unreadable.

After trying the dataframe methods, I found what appears to be a cropping setting.

In Spyder I used:

pd.set_option('expand_frame_repr', False)
print(dataframe)

This method explains why increasing max_column didn't help me previously.

You can specify a maximum number for rows or columns using pd.set_options(display.max_columns=1000)

But you don't have to set an arbitrary value, but rather use None instead to make sure every size will be covered.

For rows, use:

pd.set_option('display.max_rows', None)

And for columns, use:

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

It is a result of the display width. You can use the following set_options():

pd.set_options(display.width=1000) #make huge

You may also have to raise max columns but it should be smart enough to adjust automatically after you make width bigger:

pd.set_options(display.max_columns=None)
Related