Search code examples
pythonpython-3.xpandasvisual-studio-code

Showing all rows and columns of Pandas dataframe


I am working with python 3 and the pandas package in visual studio code and I the print() function is not displaying correctly.

For example when I am using df.head() it looks good.

df.head() example

But If I use the print() statement I no longer see all of the columns next to each other, some of them get dragged down for some reason. And I can't see the entire data

print(df) example

Anyone knows what I can do to see the entire data, and all of the columns next to each other?


Solution

  • The problem comes from library pandas that cuts part of your DataFrame when it's too long.

    To show all rows and columns, use:

    pandas.set_option('display.max_rows', None)
    pandas.set_option('display.max_columns', None)
    

    If you use an "old" pandas version use instead:

    pandas.set_option('max_row', None)