In this article we will discuss how to print a big dataframe without any truncation.

Let’s create a very big dataframe with 67 rows and 27 columns i.e.

Confirm the dataframe’s size by checking the number of columns and rows in the dataframe empDFObj,

Output:

Now let’s try printing the contents of the dataframe,

Output:

By default our complete contents of out dataframe are not printed, output got truncated. It printed only 10 rows (first & last 5 rows) instead of 63 and 12 columns instead of complete 27, all the remaining data is truncated. Now what if we want to print the full dataframe i.e. all 63 rows and 27 columns without any truncation ?

Display full contents of a dataframe

Pandas provides an operation system to customize the behavior & display related stuff. Using this options module we can configure the display to show the complete dataframe instead of truncated one. A function set_option() is provided in pandas to set these kind of options,

It sets the value of the specified option. Let’s use this to display full contents of a dataframe.

So, to display complete contents of a dataframe without any kind of truncation, we need to set these 4 options,

Let’s understand each of these options one by one.

Setting to display All rows of Dataframe

In pandas when we print a dataframe, it displays at max_rows number of rows. If we have more rows, then it truncates the rows.

This option represents the maximum number of rows that pandas will display while printing a dataframe. Default value of max_rows is 10.
If set to ‘None‘ then it means unlimited i.e. pandas will display all the rows in dataframe. Let’s set it to None while printing the contents of above created dataframe empDfObj,

Now let’s check the contents of dataframe again,

Output:

Now it printed all the 63 rows. But still columns are truncated. Let’s see to handle that,

Setting to display All Columns in Dataframe

By default only 4 columns were printed instead of all 27. To print all the columns we need to set following option to None i.e.

By setting this to None, we instruct pandas that it should not truncate columns and display all of them. Let’s try it with dataframe created above i.e. empDfObj,

Now let’s check the contents of dataframe empDfObj again,

Output:

Now it printed all the 27 columns. Although all columns were printed, but in wrapped manner. That’s because pandas will correctly auto-detect the width of the terminal and switch to a wrapped format in case all columns would not fit in same line.

Now let’s see how to fit all columns in same line,

Setting to display Dataframe with full width i.e. all columns in a line

To fit all the columns in same line we need to maximize the terminal width. That can be done by using following option,

If set to None and pandas will correctly auto-detect the width of dataframe and will display all columns in single line. Let’s try it with dataframe created above i.e. empDfObj,

Now let’s check the contents of dataframe empDfObj again,

Output:

Now it printed all the 27 columns in the single line. But, it truncated the contents of column ‘ C’. Let’s see how to handle that,

Setting to display Dataframe by maximizing column width

We can use the option,

It is set to maximize the width in characters of a column in the dataframe while printing. When set to None, pandas will auto detect the max size of column and print contents of that column without truncated the contents. Let’s try it with dataframe created above i.e. empDfObj,

Now let’s check the contents of dataframe empDfObj again,

Output:

Now it printed complete contents of column ‘C’ without truncation.

So, to print basically to print all the contents of a dataframe, use following settings,

Complete example is as follows,

Output: