Search code examples
pandasipythonjupyter-lab

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


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.


Solution

  • 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.