7

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.

2
  • do not use the print(df) statement but just df. Commented Oct 12, 2020 at 19:21
  • Thanks. But it does not solve problems. Yes, it work, but work only in jupyter and if call df in separate cell. Commented Oct 12, 2020 at 22:24

3 Answers 3

8

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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)

1 Comment

Isn't this still constrained by display.width even for unlimited cols?
0

It is a result of the display width, which by default is smaller. You can use the following set_option():

pd.set_option(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_option(display.max_columns=None)

2 Comments

Thanks. pd.set_option("display.width", 1000) Turn off cropping.
Glad it works. If this helped to solve your problem consider marking it as an accepted answer. This helps others users of stack overflow find the answers they need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.