Display all dataframe columns in a Jupyter Python Notebook
I know this question is a little old but the following worked for me in a Jupyter Notebook running pandas 0.22.0 and Python 3:
import pandas as pd
pd.set_option('display.max_columns', <number of columns>)
You can do the same for the rows too:
pd.set_option('display.max_rows', <number of rows>)
This saves importing IPython, and there are more options in the pandas.set_option documentation: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.set_option.html
Try the display max_columns
setting as follows:
import pandas as pd
from IPython.display import display
df = pd.read_csv("some_data.csv")
pd.options.display.max_columns = None
display(df)
Or
pd.set_option('display.max_columns', None)
Pandas 0.11.0 backwards
This is deprecated but in versions of Pandas older than 0.11.0 the max_columns
setting is specified as follows:
pd.set_printoptions(max_columns=500)
Python 3.x for large (but not too large) DataFrames
Maybe because I have an older version of pandas but on Jupyter notebook this work for me
import pandas as pd
from IPython.core.display import HTML
df=pd.read_pickle('Data1')
display(HTML(df.to_html()))
I recommend setting the display options inside a context manager so that it only affects a single output. I usually prefer "pretty" html-output, and define a function force_show_all(df)
for displaying the DataFrame df
:
from IPython.core.display import display, HTML
def force_show_all(df):
with pd.option_context('display.max_rows', None, 'display.max_columns', None, 'display.width', None):
display(HTML(df.to_html()))
# ... now when you're ready to fully display df:
force_show_all(df)
As others have mentioned, please be cautious to only call this on a reasonably-sized dataframe.