Updated On : Sep-02,2021 Time Investment : ~30 mins

Simple Guide to Set Pandas Options to Better Display DataFrames

Pandas is one the most favorite tool of data scientists for tabular data analysis nowadays. It provides a faster and efficient API to work with tabular data. During analysis when we display data frame, some display behaviors like how many rows to display, how many columns to display, the precision of floats in a data frame, column widths, etc are set to default values by Pandas. We might sometimes need to tweak these defaults in some situations according to our needs.

Pandas let us modify these default behavior by providing various methods. It even let us modify this behavior by using options attribute of pandas. As a part of this tutorial, we'll try to explain with simple examples how we can tweak these default behaviors.

Important Sections

Below is a list of topics that we'll be covering as a part of this tutorial.

We'll start by importing the pandas library and creating a dataframe of size 70 rows and 25 columns with random floats in the range 0-1 in it. We'll try to explain list of the below-mentioned options through our examples. Pandas do provide many more options but we have not covered all of them as a part of this tutorial. We have included commonly used options to make the tutorial simple and easy to follow through.

  • display.max_columns
  • display.max_rows
  • display.min_rows
  • display.max_info_columns
  • display.max_info_rows
  • display.max_colwidth
  • display.chop_threshold
  • display.memory_usage
  • display.show_dimensions
  • display.large_repr
  • display.precision
  • display.colheader_justify

We'll keep on explaining options as we go ahead with using them in different examples.

NOTE

Please make a note that all these options will only modify the presentation of data frame and not actual contents of data frame.

import pandas as pd
import numpy as np
data = np.random.random((70,25))

df = pd.DataFrame(data=data, columns=["Column%d"%(i+1) for i in range(25)])

df
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 ... Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.184588 0.144494 0.220359 0.343531 0.731051 0.275833 0.381695 0.796633 0.430259 0.876371 ... 0.684205 0.577935 0.914046 0.136737 0.632392 0.735557 0.852238 0.856759 0.330864 0.753213
1 0.721353 0.366603 0.894318 0.331279 0.941758 0.285863 0.444992 0.498363 0.779727 0.500529 ... 0.059706 0.217124 0.623476 0.488818 0.358538 0.840696 0.084952 0.593708 0.404494 0.263645
2 0.945869 0.796354 0.423261 0.273475 0.897543 0.849198 0.591911 0.645442 0.379223 0.666719 ... 0.020077 0.457074 0.798625 0.881347 0.967183 0.198972 0.942167 0.540091 0.648999 0.123289
3 0.037596 0.560387 0.710994 0.257847 0.806563 0.585484 0.779893 0.972912 0.731658 0.060405 ... 0.294189 0.615435 0.061615 0.287465 0.374607 0.380160 0.488677 0.844854 0.733770 0.114156
4 0.227857 0.929377 0.009852 0.476746 0.593925 0.504822 0.404113 0.323355 0.561213 0.046252 ... 0.941905 0.073999 0.814547 0.963490 0.035510 0.507574 0.105525 0.214415 0.847700 0.890027
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
65 0.798495 0.899930 0.879697 0.410523 0.336701 0.450274 0.889275 0.802456 0.620030 0.565540 ... 0.585681 0.587722 0.839363 0.761979 0.311326 0.920148 0.887574 0.057103 0.371759 0.845205
66 0.785735 0.813157 0.300188 0.395585 0.149754 0.601657 0.740157 0.210366 0.777523 0.768194 ... 0.261670 0.956656 0.481399 0.601526 0.153413 0.815635 0.874919 0.247581 0.386464 0.327894
67 0.113022 0.184803 0.952482 0.381586 0.888141 0.950874 0.711286 0.624093 0.979744 0.076829 ... 0.714909 0.988277 0.382353 0.086678 0.495954 0.230577 0.465815 0.653704 0.746532 0.632889
68 0.507982 0.225934 0.613693 0.613308 0.000538 0.366097 0.413763 0.611471 0.741501 0.188538 ... 0.688929 0.583748 0.746735 0.655962 0.731675 0.276506 0.988863 0.968679 0.834988 0.280728
69 0.842077 0.073247 0.493358 0.885131 0.394345 0.576739 0.411708 0.805430 0.665720 0.442630 ... 0.064674 0.833661 0.508584 0.457716 0.221259 0.842794 0.129998 0.114098 0.761531 0.305855

70 rows × 25 columns

Describe Options

As a part of our first section, we'll explain how we can retrieve information about a particular option. Pandas provide us with a method named describe_option() which can be used for this purpose.


  • describe_option(pattern) - This method takes as input string which can be actual full option name or partial option name. If we provide a partial option name then it'll try to match the best option with it. It returns details about an option such as how to use it, default value, current value, etc.

Below we have used describe_option() method to retrieve description about display.max_columns and display.precision options respectively. We can notice that in the case of display.precision, we have only provided a partial name, and still it was able to retrieve details about it.


  • display.max_columns - This options accepts integer value. The value provided in this parameter will decide how many columns to display in the jupyter notebook. If the data frame has more columns than this number then they will be collapsed and '...' pattern will be displayed in the center of the data frame. The default value of this option is 20 columns. We can notice from the above presentation of the data frame that only columns 1-10 and 16-25 are displayed in it. If we set this option to None then no limit will be applied and all columns will be displayed.

  • display.precision - This options accepts integer value. This value will be used to decide how many digits to display after floating points. The default value for this option is 6.


We'll explain in the set options section how to modify these options.

pd.describe_option("display.max_columns")
display.max_columns : int
    If max_cols is exceeded, switch to truncate view. Depending on
    `large_repr`, objects are either centrally truncated or printed as
    a summary view. 'None' value means unlimited.

    In case python/IPython is running in a terminal and `large_repr`
    equals 'truncate' this can be set to 0 and pandas will auto-detect
    the width of the terminal and print a truncated object which fits
    the screen width. The IPython notebook, IPython qtconsole, or IDLE
    do not run in a terminal and hence it is not possible to do
    correct auto-detection.
    [default: 20] [currently: 20]
pd.describe_option("precision")
display.precision : int
    Floating point output precision in terms of number of places after the
    decimal, for regular formatting as well as scientific notation. Similar
    to ``precision`` in :meth:`numpy.set_printoptions`.
    [default: 6] [currently: 6]

Get Options Values

As a part of this section, we'll explain how we can retrieve the existing value of a particular option. There are two ways to do this.

  • Using get_option() Method.
  • Using options attribute of pandas module.

  • get_option(pattern) - This method takes pattern about option just like describe_option() method and returns current setting of option.

We have explained below with simple examples how we can provide full option name as well as partial option name and it'll still return the current value.

print("How many columns to display by default? : {}".format(pd.get_option("display.max_columns")))
print("How many rows    to display by default? : {}".format(pd.get_option("display.max_rows")))
print()
print("How many columns to display by default? : {}".format(pd.get_option("max_colu")))
print("How many rows    to display by default? : {}".format(pd.get_option("display.max_ro")))
How many columns to display by default? : 20
How many rows    to display by default? : 60

How many columns to display by default? : 20
How many rows    to display by default? : 60

  • display.max_rows - This option takes integer value just like max_columns option. It decides how many rows to display at max. If rows in the data frame are more than this option then extra rows will be collapsed and '...' representation will be used in between. The default value of this option is 60.
  • display.min_rows - This option takes integer value just like max_rows. It works with max_rows option. When a number of rows in the data frame crosses max_rows and we generate truncated rows representation then the number set of this option will be used to determine how many rows to display. The default value of this option is 10.

We can notice from the data frame display earlier that as it has 70 rows which are more than 60 rows value of max_rows option, it truncates rows. It only displays 10 rows which is the current value of min_rows option.


  • options Attribute - Pandas provides top-level attribute named options which can be treated like a class object and can be used to get and set values of a particular option. It lets us follow a pattern that we use to set/get class attributes.

Below we have explained how we can retrieve values of options using options attribute of the pandas module.

print("How many columns to display by default? : {}".format(pd.options.display.max_columns))
print("How many rows    to display by default? : {}".format(pd.options.display.max_rows))
How many columns to display by default? : 20
How many rows    to display by default? : 60

Set Options to Modify Default Behavior

As a part of this section, we'll explain with simple examples how we can set the values of options to modify the default behavior. There are two ways to do this.

  • Using set_option() method.
  • Modifying options attribute of pandas module.

  • set_option(pattern, value) - This method takes as input two values. The first value is a string which can be a full option name or partial name and section value is a value that we want to set for that option. Pandas will try to find out actual option name if we provide partial name like it does in get_option() and describe_option() methods.

Modify Max Columns to Display

Below we have modified maximum columns display option and set it to 25 columns using set_option() method. We can notice from dataframe representation that it now displays all columns of our data frame. We have modified the value from the default of 20 to 25.

pd.set_option("display.max_columns", 25)
df
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 Column11 Column12 Column13 Column14 Column15 Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.184588 0.144494 0.220359 0.343531 0.731051 0.275833 0.381695 0.796633 0.430259 0.876371 0.976755 0.472714 0.167219 0.380681 0.041427 0.684205 0.577935 0.914046 0.136737 0.632392 0.735557 0.852238 0.856759 0.330864 0.753213
1 0.721353 0.366603 0.894318 0.331279 0.941758 0.285863 0.444992 0.498363 0.779727 0.500529 0.756796 0.113007 0.766567 0.976172 0.070463 0.059706 0.217124 0.623476 0.488818 0.358538 0.840696 0.084952 0.593708 0.404494 0.263645
2 0.945869 0.796354 0.423261 0.273475 0.897543 0.849198 0.591911 0.645442 0.379223 0.666719 0.751458 0.651565 0.068140 0.082032 0.818177 0.020077 0.457074 0.798625 0.881347 0.967183 0.198972 0.942167 0.540091 0.648999 0.123289
3 0.037596 0.560387 0.710994 0.257847 0.806563 0.585484 0.779893 0.972912 0.731658 0.060405 0.180700 0.215177 0.955551 0.915412 0.212019 0.294189 0.615435 0.061615 0.287465 0.374607 0.380160 0.488677 0.844854 0.733770 0.114156
4 0.227857 0.929377 0.009852 0.476746 0.593925 0.504822 0.404113 0.323355 0.561213 0.046252 0.952211 0.791182 0.013024 0.464821 0.391342 0.941905 0.073999 0.814547 0.963490 0.035510 0.507574 0.105525 0.214415 0.847700 0.890027
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
65 0.798495 0.899930 0.879697 0.410523 0.336701 0.450274 0.889275 0.802456 0.620030 0.565540 0.585079 0.686120 0.363934 0.495442 0.038762 0.585681 0.587722 0.839363 0.761979 0.311326 0.920148 0.887574 0.057103 0.371759 0.845205
66 0.785735 0.813157 0.300188 0.395585 0.149754 0.601657 0.740157 0.210366 0.777523 0.768194 0.391869 0.572614 0.410180 0.802801 0.829115 0.261670 0.956656 0.481399 0.601526 0.153413 0.815635 0.874919 0.247581 0.386464 0.327894
67 0.113022 0.184803 0.952482 0.381586 0.888141 0.950874 0.711286 0.624093 0.979744 0.076829 0.425918 0.915160 0.702043 0.753486 0.912746 0.714909 0.988277 0.382353 0.086678 0.495954 0.230577 0.465815 0.653704 0.746532 0.632889
68 0.507982 0.225934 0.613693 0.613308 0.000538 0.366097 0.413763 0.611471 0.741501 0.188538 0.862204 0.857585 0.681589 0.597970 0.112004 0.688929 0.583748 0.746735 0.655962 0.731675 0.276506 0.988863 0.968679 0.834988 0.280728
69 0.842077 0.073247 0.493358 0.885131 0.394345 0.576739 0.411708 0.805430 0.665720 0.442630 0.731525 0.024916 0.764527 0.081460 0.322126 0.064674 0.833661 0.508584 0.457716 0.221259 0.842794 0.129998 0.114098 0.761531 0.305855

70 rows × 25 columns

Below we have again reset maximum columns to 20 but this time through options attribute of pandas module.

pd.options.display.max_columns = 20
df
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 ... Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.184588 0.144494 0.220359 0.343531 0.731051 0.275833 0.381695 0.796633 0.430259 0.876371 ... 0.684205 0.577935 0.914046 0.136737 0.632392 0.735557 0.852238 0.856759 0.330864 0.753213
1 0.721353 0.366603 0.894318 0.331279 0.941758 0.285863 0.444992 0.498363 0.779727 0.500529 ... 0.059706 0.217124 0.623476 0.488818 0.358538 0.840696 0.084952 0.593708 0.404494 0.263645
2 0.945869 0.796354 0.423261 0.273475 0.897543 0.849198 0.591911 0.645442 0.379223 0.666719 ... 0.020077 0.457074 0.798625 0.881347 0.967183 0.198972 0.942167 0.540091 0.648999 0.123289
3 0.037596 0.560387 0.710994 0.257847 0.806563 0.585484 0.779893 0.972912 0.731658 0.060405 ... 0.294189 0.615435 0.061615 0.287465 0.374607 0.380160 0.488677 0.844854 0.733770 0.114156
4 0.227857 0.929377 0.009852 0.476746 0.593925 0.504822 0.404113 0.323355 0.561213 0.046252 ... 0.941905 0.073999 0.814547 0.963490 0.035510 0.507574 0.105525 0.214415 0.847700 0.890027
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
65 0.798495 0.899930 0.879697 0.410523 0.336701 0.450274 0.889275 0.802456 0.620030 0.565540 ... 0.585681 0.587722 0.839363 0.761979 0.311326 0.920148 0.887574 0.057103 0.371759 0.845205
66 0.785735 0.813157 0.300188 0.395585 0.149754 0.601657 0.740157 0.210366 0.777523 0.768194 ... 0.261670 0.956656 0.481399 0.601526 0.153413 0.815635 0.874919 0.247581 0.386464 0.327894
67 0.113022 0.184803 0.952482 0.381586 0.888141 0.950874 0.711286 0.624093 0.979744 0.076829 ... 0.714909 0.988277 0.382353 0.086678 0.495954 0.230577 0.465815 0.653704 0.746532 0.632889
68 0.507982 0.225934 0.613693 0.613308 0.000538 0.366097 0.413763 0.611471 0.741501 0.188538 ... 0.688929 0.583748 0.746735 0.655962 0.731675 0.276506 0.988863 0.968679 0.834988 0.280728
69 0.842077 0.073247 0.493358 0.885131 0.394345 0.576739 0.411708 0.805430 0.665720 0.442630 ... 0.064674 0.833661 0.508584 0.457716 0.221259 0.842794 0.129998 0.114098 0.761531 0.305855

70 rows × 25 columns

Modify Max Rows to Display

Below we have modified the maximum rows to 80 which is more than the number of rows of our dataframe. We can notice that pandas is now displaying all rows of the data frame.

pd.set_option("display.max_rows", 80)
df
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 ... Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.184588 0.144494 0.220359 0.343531 0.731051 0.275833 0.381695 0.796633 0.430259 0.876371 ... 0.684205 0.577935 0.914046 0.136737 0.632392 0.735557 0.852238 0.856759 0.330864 0.753213
1 0.721353 0.366603 0.894318 0.331279 0.941758 0.285863 0.444992 0.498363 0.779727 0.500529 ... 0.059706 0.217124 0.623476 0.488818 0.358538 0.840696 0.084952 0.593708 0.404494 0.263645
2 0.945869 0.796354 0.423261 0.273475 0.897543 0.849198 0.591911 0.645442 0.379223 0.666719 ... 0.020077 0.457074 0.798625 0.881347 0.967183 0.198972 0.942167 0.540091 0.648999 0.123289
3 0.037596 0.560387 0.710994 0.257847 0.806563 0.585484 0.779893 0.972912 0.731658 0.060405 ... 0.294189 0.615435 0.061615 0.287465 0.374607 0.380160 0.488677 0.844854 0.733770 0.114156
4 0.227857 0.929377 0.009852 0.476746 0.593925 0.504822 0.404113 0.323355 0.561213 0.046252 ... 0.941905 0.073999 0.814547 0.963490 0.035510 0.507574 0.105525 0.214415 0.847700 0.890027
5 0.664160 0.908081 0.034409 0.150037 0.554313 0.944290 0.829889 0.437333 0.655066 0.187280 ... 0.864926 0.508549 0.165847 0.981163 0.770473 0.655127 0.815400 0.944873 0.033128 0.059737
6 0.540152 0.855742 0.114633 0.617741 0.716761 0.869788 0.400228 0.631317 0.162027 0.261517 ... 0.447225 0.619085 0.462788 0.995170 0.591217 0.291742 0.700979 0.986330 0.872818 0.168602
7 0.111043 0.367750 0.002109 0.723567 0.648873 0.439307 0.464016 0.520615 0.601488 0.777082 ... 0.089580 0.908735 0.893017 0.767935 0.367200 0.600942 0.072072 0.039936 0.544188 0.517689
8 0.326784 0.805520 0.038914 0.777494 0.969911 0.052782 0.892729 0.378053 0.434680 0.873003 ... 0.949888 0.767683 0.741452 0.691505 0.554390 0.046057 0.557984 0.276532 0.339130 0.211745
9 0.855805 0.056045 0.151296 0.835526 0.565936 0.996247 0.960923 0.781047 0.357407 0.872240 ... 0.625174 0.355202 0.499390 0.490519 0.740207 0.439999 0.551455 0.750388 0.080013 0.623462
10 0.707707 0.542882 0.266868 0.888696 0.837262 0.054590 0.315526 0.134082 0.145577 0.469024 ... 0.632437 0.539190 0.262740 0.806811 0.508233 0.455566 0.996483 0.152049 0.051338 0.556847
11 0.154867 0.673695 0.514100 0.262723 0.095300 0.207968 0.247031 0.261612 0.038172 0.935153 ... 0.719740 0.516551 0.425829 0.386186 0.423528 0.440288 0.534635 0.931956 0.409411 0.471416
12 0.714530 0.647634 0.967713 0.225742 0.765332 0.637259 0.708573 0.550539 0.771907 0.112774 ... 0.122304 0.962312 0.718519 0.677102 0.460705 0.516576 0.469209 0.659791 0.427048 0.513725
13 0.539357 0.419139 0.639028 0.589789 0.350477 0.066916 0.332343 0.683114 0.170034 0.531403 ... 0.988971 0.183563 0.170314 0.084223 0.230749 0.775808 0.393761 0.978366 0.317142 0.226110
14 0.412190 0.082481 0.293812 0.934841 0.877373 0.879521 0.618028 0.962169 0.760019 0.165893 ... 0.175853 0.728555 0.479218 0.353136 0.196134 0.885751 0.325787 0.640792 0.619186 0.387798
15 0.710603 0.851927 0.223594 0.667649 0.886054 0.897400 0.041765 0.708884 0.024022 0.191414 ... 0.281251 0.562283 0.381957 0.958697 0.012023 0.801099 0.450367 0.321855 0.285684 0.031542
16 0.226174 0.289193 0.024838 0.922013 0.503057 0.810218 0.221127 0.057150 0.173522 0.285343 ... 0.318502 0.860916 0.419574 0.749724 0.914087 0.653918 0.343086 0.136294 0.142177 0.447653
17 0.086036 0.884575 0.376852 0.458598 0.229739 0.323341 0.216547 0.787039 0.678946 0.873531 ... 0.889079 0.662551 0.916757 0.114380 0.562888 0.907607 0.271519 0.136344 0.640300 0.363010
18 0.950659 0.107902 0.232458 0.303881 0.181975 0.702302 0.405413 0.599669 0.916219 0.952570 ... 0.914339 0.411023 0.652123 0.593390 0.726014 0.533833 0.124624 0.179895 0.055753 0.367374
19 0.767324 0.975419 0.293430 0.135435 0.122212 0.490970 0.301175 0.839547 0.247698 0.979909 ... 0.982596 0.814188 0.670918 0.552619 0.383923 0.329018 0.725435 0.377663 0.722375 0.597911
20 0.886010 0.018624 0.252777 0.731721 0.170034 0.551345 0.980317 0.200404 0.497325 0.447728 ... 0.817320 0.347433 0.813878 0.323896 0.385170 0.080033 0.133468 0.179208 0.666689 0.971020
21 0.844537 0.427437 0.171859 0.633968 0.626357 0.635044 0.089994 0.710119 0.594798 0.712599 ... 0.704228 0.312864 0.842855 0.397675 0.535999 0.895286 0.683585 0.893389 0.593863 0.694328
22 0.254088 0.480991 0.647814 0.877612 0.380551 0.508967 0.435076 0.684825 0.104003 0.535021 ... 0.592561 0.928040 0.135215 0.096808 0.894140 0.069496 0.994549 0.326670 0.297965 0.162193
23 0.437290 0.158794 0.537736 0.856252 0.219007 0.438551 0.001824 0.571584 0.241107 0.668878 ... 0.240479 0.548970 0.310336 0.753390 0.047645 0.526148 0.485921 0.742283 0.611023 0.804600
24 0.863987 0.864417 0.853168 0.646889 0.921567 0.458231 0.602380 0.749582 0.103935 0.078050 ... 0.086124 0.543589 0.218204 0.842407 0.198074 0.495835 0.878715 0.954443 0.842569 0.539174
25 0.908973 0.029371 0.802580 0.186579 0.994920 0.792218 0.344782 0.476065 0.517919 0.814510 ... 0.712061 0.467008 0.600187 0.144133 0.760575 0.311756 0.135651 0.901379 0.017758 0.351458
26 0.966576 0.602765 0.070609 0.317348 0.009513 0.365808 0.784528 0.263356 0.550204 0.943848 ... 0.484405 0.412727 0.670528 0.503541 0.714544 0.624624 0.566450 0.807474 0.534359 0.333634
27 0.479220 0.749753 0.986208 0.269198 0.332496 0.492480 0.894839 0.685235 0.004117 0.043830 ... 0.564610 0.211438 0.056227 0.959299 0.163408 0.865722 0.405214 0.310682 0.903218 0.166733
28 0.440104 0.039097 0.938125 0.284548 0.113731 0.324031 0.439193 0.115087 0.253869 0.213334 ... 0.834908 0.794675 0.209317 0.351236 0.484703 0.854755 0.626262 0.894995 0.341192 0.979999
29 0.450581 0.337708 0.638536 0.307000 0.814616 0.569577 0.993356 0.477276 0.027773 0.339498 ... 0.761605 0.259743 0.215097 0.375563 0.458409 0.218886 0.135514 0.158554 0.000960 0.415957
30 0.710718 0.016463 0.094065 0.413063 0.389305 0.296404 0.018643 0.973434 0.482529 0.896808 ... 0.073812 0.616804 0.281534 0.849445 0.427223 0.978688 0.101879 0.325991 0.026482 0.675448
31 0.994783 0.581417 0.642990 0.187778 0.120590 0.322226 0.315292 0.848420 0.631466 0.927877 ... 0.689750 0.569225 0.209454 0.926524 0.739159 0.023987 0.913384 0.886052 0.728478 0.590927
32 0.454040 0.913367 0.763088 0.917878 0.116524 0.515351 0.015627 0.240662 0.578310 0.506549 ... 0.989989 0.076968 0.518571 0.972219 0.733205 0.598217 0.513824 0.610017 0.065206 0.363980
33 0.801830 0.402936 0.085547 0.748554 0.427546 0.463883 0.902379 0.816046 0.295814 0.959479 ... 0.618385 0.678652 0.041313 0.597345 0.843527 0.724964 0.198188 0.999403 0.769027 0.204517
34 0.105869 0.926904 0.245412 0.230573 0.675308 0.202558 0.151878 0.377364 0.298879 0.808496 ... 0.057346 0.262988 0.363284 0.429321 0.189320 0.452330 0.868304 0.651142 0.873020 0.712429
35 0.193409 0.019434 0.109868 0.004339 0.789232 0.204218 0.218865 0.587106 0.445115 0.386927 ... 0.775689 0.402072 0.860941 0.573424 0.913064 0.127865 0.723009 0.680258 0.451426 0.889079
36 0.230001 0.100422 0.688438 0.831594 0.815913 0.142813 0.741943 0.754265 0.626268 0.048226 ... 0.848366 0.717152 0.453898 0.557210 0.860404 0.922190 0.933695 0.810617 0.800066 0.767754
37 0.707604 0.901610 0.140644 0.009417 0.745643 0.383997 0.005998 0.738917 0.268108 0.972591 ... 0.492394 0.053785 0.135934 0.240740 0.363675 0.515271 0.538818 0.863100 0.334764 0.221060
38 0.227849 0.275190 0.735994 0.251943 0.774193 0.893907 0.380651 0.602345 0.812799 0.826846 ... 0.750576 0.827926 0.517128 0.972679 0.345969 0.371649 0.990429 0.741643 0.147165 0.779047
39 0.408287 0.726112 0.599019 0.399557 0.647511 0.422403 0.069553 0.750626 0.802162 0.978599 ... 0.506200 0.874581 0.231177 0.029876 0.352507 0.194167 0.986697 0.363142 0.191244 0.672595
40 0.070279 0.520130 0.586946 0.171738 0.642893 0.758870 0.191472 0.684346 0.147900 0.269830 ... 0.864472 0.196934 0.174957 0.601770 0.737757 0.053067 0.389799 0.448798 0.455847 0.567200
41 0.892150 0.157280 0.025805 0.180531 0.514688 0.121467 0.207972 0.486247 0.501503 0.505264 ... 0.504418 0.003305 0.118906 0.126078 0.869016 0.038424 0.639921 0.314488 0.446503 0.327203
42 0.066994 0.750233 0.748451 0.404325 0.442776 0.641104 0.697687 0.385261 0.325429 0.797123 ... 0.754794 0.196740 0.298421 0.370713 0.420741 0.444511 0.527007 0.294383 0.325907 0.908197
43 0.821830 0.924825 0.098836 0.658566 0.574558 0.795963 0.588508 0.242464 0.427039 0.966281 ... 0.851965 0.960941 0.391180 0.124206 0.873074 0.947989 0.309699 0.303015 0.127884 0.249931
44 0.663866 0.188455 0.537859 0.623510 0.704454 0.430267 0.728948 0.451012 0.026536 0.861262 ... 0.754363 0.069568 0.759447 0.175694 0.512351 0.988948 0.513522 0.208476 0.954547 0.300497
45 0.705035 0.484753 0.400979 0.549746 0.091355 0.305367 0.757829 0.077044 0.584681 0.724965 ... 0.163371 0.319997 0.041784 0.044992 0.435499 0.210591 0.130503 0.854157 0.268405 0.233800
46 0.148845 0.338137 0.172033 0.295572 0.152926 0.043689 0.861013 0.645503 0.329513 0.899285 ... 0.872663 0.575978 0.198636 0.393568 0.001405 0.801172 0.119428 0.405122 0.892502 0.354516
47 0.262433 0.943306 0.585878 0.476753 0.476021 0.248961 0.033250 0.426974 0.011094 0.025637 ... 0.461629 0.904429 0.429718 0.422534 0.274365 0.450561 0.668339 0.625603 0.253046 0.930823
48 0.040799 0.815473 0.135369 0.648973 0.869085 0.681890 0.914273 0.359228 0.582177 0.155867 ... 0.904846 0.146556 0.711682 0.921989 0.051516 0.121222 0.538834 0.346720 0.578281 0.451195
49 0.660815 0.177575 0.280384 0.277794 0.177575 0.218147 0.479055 0.450827 0.602637 0.761615 ... 0.411548 0.486290 0.780825 0.059796 0.327315 0.061378 0.345981 0.911617 0.618819 0.507479
50 0.157320 0.264841 0.705539 0.973711 0.833450 0.443143 0.083568 0.219078 0.757274 0.837699 ... 0.371966 0.606088 0.526089 0.105063 0.329013 0.439354 0.705734 0.260431 0.629056 0.654469
51 0.266197 0.016127 0.969096 0.939964 0.002554 0.941604 0.974288 0.892608 0.998793 0.191126 ... 0.310360 0.548588 0.985727 0.963248 0.164669 0.090312 0.854464 0.641608 0.024812 0.073666
52 0.141108 0.466006 0.775017 0.090079 0.844988 0.666512 0.231482 0.664112 0.722006 0.241913 ... 0.411263 0.396832 0.585433 0.802998 0.066356 0.197571 0.721130 0.240404 0.519718 0.854310
53 0.055144 0.954262 0.076378 0.151782 0.129381 0.520039 0.323979 0.840924 0.849266 0.274658 ... 0.091987 0.680931 0.868032 0.552125 0.475715 0.281889 0.962958 0.680096 0.546711 0.800402
54 0.480728 0.486073 0.573982 0.127941 0.836796 0.295975 0.384446 0.943825 0.373925 0.372635 ... 0.907503 0.042633 0.914681 0.670072 0.288250 0.878968 0.197964 0.437065 0.600687 0.559742
55 0.185216 0.107098 0.090925 0.193163 0.573702 0.783119 0.986354 0.368560 0.626767 0.938909 ... 0.660345 0.467321 0.497959 0.517785 0.522817 0.527030 0.808343 0.884736 0.586219 0.819818
56 0.605227 0.957251 0.697292 0.804860 0.766497 0.506230 0.215191 0.244872 0.825070 0.363857 ... 0.547901 0.237897 0.945737 0.997945 0.010280 0.621374 0.137374 0.510710 0.033314 0.231646
57 0.609197 0.284590 0.752457 0.010410 0.814117 0.221919 0.573248 0.349055 0.479525 0.524208 ... 0.691053 0.597417 0.744839 0.040520 0.301477 0.221386 0.267802 0.374082 0.722510 0.694495
58 0.636722 0.829982 0.085543 0.457014 0.513452 0.648427 0.739993 0.371985 0.933507 0.549614 ... 0.974204 0.669218 0.619603 0.518959 0.615935 0.829708 0.127674 0.839253 0.327830 0.769837
59 0.071957 0.145293 0.605460 0.041722 0.751571 0.423749 0.203972 0.798032 0.645851 0.363504 ... 0.948710 0.548831 0.119151 0.348000 0.639268 0.426192 0.658791 0.836485 0.028302 0.148027
60 0.232336 0.721555 0.908649 0.007801 0.413158 0.157547 0.938929 0.599144 0.520335 0.822662 ... 0.771366 0.811174 0.777192 0.023283 0.296063 0.998900 0.200806 0.668894 0.677321 0.393792
61 0.762381 0.250470 0.351132 0.403117 0.717709 0.951285 0.769424 0.494296 0.120866 0.462440 ... 0.337418 0.111266 0.812205 0.495001 0.848119 0.585495 0.841752 0.082504 0.509273 0.499821
62 0.682170 0.054022 0.620629 0.669933 0.789462 0.765265 0.009614 0.500403 0.794490 0.190056 ... 0.335373 0.350171 0.320948 0.325424 0.833244 0.879453 0.730606 0.358231 0.826510 0.873010
63 0.392384 0.003795 0.593325 0.134927 0.072760 0.914869 0.714621 0.821584 0.938587 0.375764 ... 0.646230 0.139179 0.474459 0.522945 0.506941 0.242923 0.075348 0.165459 0.046551 0.986102
64 0.041709 0.234257 0.868029 0.135867 0.518269 0.091134 0.400327 0.108465 0.283822 0.594082 ... 0.114216 0.615886 0.125736 0.675916 0.653570 0.477913 0.145235 0.631270 0.200574 0.192801
65 0.798495 0.899930 0.879697 0.410523 0.336701 0.450274 0.889275 0.802456 0.620030 0.565540 ... 0.585681 0.587722 0.839363 0.761979 0.311326 0.920148 0.887574 0.057103 0.371759 0.845205
66 0.785735 0.813157 0.300188 0.395585 0.149754 0.601657 0.740157 0.210366 0.777523 0.768194 ... 0.261670 0.956656 0.481399 0.601526 0.153413 0.815635 0.874919 0.247581 0.386464 0.327894
67 0.113022 0.184803 0.952482 0.381586 0.888141 0.950874 0.711286 0.624093 0.979744 0.076829 ... 0.714909 0.988277 0.382353 0.086678 0.495954 0.230577 0.465815 0.653704 0.746532 0.632889
68 0.507982 0.225934 0.613693 0.613308 0.000538 0.366097 0.413763 0.611471 0.741501 0.188538 ... 0.688929 0.583748 0.746735 0.655962 0.731675 0.276506 0.988863 0.968679 0.834988 0.280728
69 0.842077 0.073247 0.493358 0.885131 0.394345 0.576739 0.411708 0.805430 0.665720 0.442630 ... 0.064674 0.833661 0.508584 0.457716 0.221259 0.842794 0.129998 0.114098 0.761531 0.305855

70 rows × 25 columns

Modify Min Rows to Display

Below we have modified max rows and min rows options to modify the behavior of a number of rows getting display again. We have set max_rows to 50 which is less than our data frame rows of 70 hence rows will be truncated. We have set min_rows to 6 which will inform pandas to display 6 rows after truncation.

pd.set_option("max_rows", 50)

pd.set_option("min_rows", 6)
df
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 ... Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.184588 0.144494 0.220359 0.343531 0.731051 0.275833 0.381695 0.796633 0.430259 0.876371 ... 0.684205 0.577935 0.914046 0.136737 0.632392 0.735557 0.852238 0.856759 0.330864 0.753213
1 0.721353 0.366603 0.894318 0.331279 0.941758 0.285863 0.444992 0.498363 0.779727 0.500529 ... 0.059706 0.217124 0.623476 0.488818 0.358538 0.840696 0.084952 0.593708 0.404494 0.263645
2 0.945869 0.796354 0.423261 0.273475 0.897543 0.849198 0.591911 0.645442 0.379223 0.666719 ... 0.020077 0.457074 0.798625 0.881347 0.967183 0.198972 0.942167 0.540091 0.648999 0.123289
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
67 0.113022 0.184803 0.952482 0.381586 0.888141 0.950874 0.711286 0.624093 0.979744 0.076829 ... 0.714909 0.988277 0.382353 0.086678 0.495954 0.230577 0.465815 0.653704 0.746532 0.632889
68 0.507982 0.225934 0.613693 0.613308 0.000538 0.366097 0.413763 0.611471 0.741501 0.188538 ... 0.688929 0.583748 0.746735 0.655962 0.731675 0.276506 0.988863 0.968679 0.834988 0.280728
69 0.842077 0.073247 0.493358 0.885131 0.394345 0.576739 0.411708 0.805430 0.665720 0.442630 ... 0.064674 0.833661 0.508584 0.457716 0.221259 0.842794 0.129998 0.114098 0.761531 0.305855

70 rows × 25 columns

Below we are trying to display the first 50 rows of the data frame and it works fine because max_rows is set to 50.

df.head(50)
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 ... Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.184588 0.144494 0.220359 0.343531 0.731051 0.275833 0.381695 0.796633 0.430259 0.876371 ... 0.684205 0.577935 0.914046 0.136737 0.632392 0.735557 0.852238 0.856759 0.330864 0.753213
1 0.721353 0.366603 0.894318 0.331279 0.941758 0.285863 0.444992 0.498363 0.779727 0.500529 ... 0.059706 0.217124 0.623476 0.488818 0.358538 0.840696 0.084952 0.593708 0.404494 0.263645
2 0.945869 0.796354 0.423261 0.273475 0.897543 0.849198 0.591911 0.645442 0.379223 0.666719 ... 0.020077 0.457074 0.798625 0.881347 0.967183 0.198972 0.942167 0.540091 0.648999 0.123289
3 0.037596 0.560387 0.710994 0.257847 0.806563 0.585484 0.779893 0.972912 0.731658 0.060405 ... 0.294189 0.615435 0.061615 0.287465 0.374607 0.380160 0.488677 0.844854 0.733770 0.114156
4 0.227857 0.929377 0.009852 0.476746 0.593925 0.504822 0.404113 0.323355 0.561213 0.046252 ... 0.941905 0.073999 0.814547 0.963490 0.035510 0.507574 0.105525 0.214415 0.847700 0.890027
5 0.664160 0.908081 0.034409 0.150037 0.554313 0.944290 0.829889 0.437333 0.655066 0.187280 ... 0.864926 0.508549 0.165847 0.981163 0.770473 0.655127 0.815400 0.944873 0.033128 0.059737
6 0.540152 0.855742 0.114633 0.617741 0.716761 0.869788 0.400228 0.631317 0.162027 0.261517 ... 0.447225 0.619085 0.462788 0.995170 0.591217 0.291742 0.700979 0.986330 0.872818 0.168602
7 0.111043 0.367750 0.002109 0.723567 0.648873 0.439307 0.464016 0.520615 0.601488 0.777082 ... 0.089580 0.908735 0.893017 0.767935 0.367200 0.600942 0.072072 0.039936 0.544188 0.517689
8 0.326784 0.805520 0.038914 0.777494 0.969911 0.052782 0.892729 0.378053 0.434680 0.873003 ... 0.949888 0.767683 0.741452 0.691505 0.554390 0.046057 0.557984 0.276532 0.339130 0.211745
9 0.855805 0.056045 0.151296 0.835526 0.565936 0.996247 0.960923 0.781047 0.357407 0.872240 ... 0.625174 0.355202 0.499390 0.490519 0.740207 0.439999 0.551455 0.750388 0.080013 0.623462
10 0.707707 0.542882 0.266868 0.888696 0.837262 0.054590 0.315526 0.134082 0.145577 0.469024 ... 0.632437 0.539190 0.262740 0.806811 0.508233 0.455566 0.996483 0.152049 0.051338 0.556847
11 0.154867 0.673695 0.514100 0.262723 0.095300 0.207968 0.247031 0.261612 0.038172 0.935153 ... 0.719740 0.516551 0.425829 0.386186 0.423528 0.440288 0.534635 0.931956 0.409411 0.471416
12 0.714530 0.647634 0.967713 0.225742 0.765332 0.637259 0.708573 0.550539 0.771907 0.112774 ... 0.122304 0.962312 0.718519 0.677102 0.460705 0.516576 0.469209 0.659791 0.427048 0.513725
13 0.539357 0.419139 0.639028 0.589789 0.350477 0.066916 0.332343 0.683114 0.170034 0.531403 ... 0.988971 0.183563 0.170314 0.084223 0.230749 0.775808 0.393761 0.978366 0.317142 0.226110
14 0.412190 0.082481 0.293812 0.934841 0.877373 0.879521 0.618028 0.962169 0.760019 0.165893 ... 0.175853 0.728555 0.479218 0.353136 0.196134 0.885751 0.325787 0.640792 0.619186 0.387798
15 0.710603 0.851927 0.223594 0.667649 0.886054 0.897400 0.041765 0.708884 0.024022 0.191414 ... 0.281251 0.562283 0.381957 0.958697 0.012023 0.801099 0.450367 0.321855 0.285684 0.031542
16 0.226174 0.289193 0.024838 0.922013 0.503057 0.810218 0.221127 0.057150 0.173522 0.285343 ... 0.318502 0.860916 0.419574 0.749724 0.914087 0.653918 0.343086 0.136294 0.142177 0.447653
17 0.086036 0.884575 0.376852 0.458598 0.229739 0.323341 0.216547 0.787039 0.678946 0.873531 ... 0.889079 0.662551 0.916757 0.114380 0.562888 0.907607 0.271519 0.136344 0.640300 0.363010
18 0.950659 0.107902 0.232458 0.303881 0.181975 0.702302 0.405413 0.599669 0.916219 0.952570 ... 0.914339 0.411023 0.652123 0.593390 0.726014 0.533833 0.124624 0.179895 0.055753 0.367374
19 0.767324 0.975419 0.293430 0.135435 0.122212 0.490970 0.301175 0.839547 0.247698 0.979909 ... 0.982596 0.814188 0.670918 0.552619 0.383923 0.329018 0.725435 0.377663 0.722375 0.597911
20 0.886010 0.018624 0.252777 0.731721 0.170034 0.551345 0.980317 0.200404 0.497325 0.447728 ... 0.817320 0.347433 0.813878 0.323896 0.385170 0.080033 0.133468 0.179208 0.666689 0.971020
21 0.844537 0.427437 0.171859 0.633968 0.626357 0.635044 0.089994 0.710119 0.594798 0.712599 ... 0.704228 0.312864 0.842855 0.397675 0.535999 0.895286 0.683585 0.893389 0.593863 0.694328
22 0.254088 0.480991 0.647814 0.877612 0.380551 0.508967 0.435076 0.684825 0.104003 0.535021 ... 0.592561 0.928040 0.135215 0.096808 0.894140 0.069496 0.994549 0.326670 0.297965 0.162193
23 0.437290 0.158794 0.537736 0.856252 0.219007 0.438551 0.001824 0.571584 0.241107 0.668878 ... 0.240479 0.548970 0.310336 0.753390 0.047645 0.526148 0.485921 0.742283 0.611023 0.804600
24 0.863987 0.864417 0.853168 0.646889 0.921567 0.458231 0.602380 0.749582 0.103935 0.078050 ... 0.086124 0.543589 0.218204 0.842407 0.198074 0.495835 0.878715 0.954443 0.842569 0.539174
25 0.908973 0.029371 0.802580 0.186579 0.994920 0.792218 0.344782 0.476065 0.517919 0.814510 ... 0.712061 0.467008 0.600187 0.144133 0.760575 0.311756 0.135651 0.901379 0.017758 0.351458
26 0.966576 0.602765 0.070609 0.317348 0.009513 0.365808 0.784528 0.263356 0.550204 0.943848 ... 0.484405 0.412727 0.670528 0.503541 0.714544 0.624624 0.566450 0.807474 0.534359 0.333634
27 0.479220 0.749753 0.986208 0.269198 0.332496 0.492480 0.894839 0.685235 0.004117 0.043830 ... 0.564610 0.211438 0.056227 0.959299 0.163408 0.865722 0.405214 0.310682 0.903218 0.166733
28 0.440104 0.039097 0.938125 0.284548 0.113731 0.324031 0.439193 0.115087 0.253869 0.213334 ... 0.834908 0.794675 0.209317 0.351236 0.484703 0.854755 0.626262 0.894995 0.341192 0.979999
29 0.450581 0.337708 0.638536 0.307000 0.814616 0.569577 0.993356 0.477276 0.027773 0.339498 ... 0.761605 0.259743 0.215097 0.375563 0.458409 0.218886 0.135514 0.158554 0.000960 0.415957
30 0.710718 0.016463 0.094065 0.413063 0.389305 0.296404 0.018643 0.973434 0.482529 0.896808 ... 0.073812 0.616804 0.281534 0.849445 0.427223 0.978688 0.101879 0.325991 0.026482 0.675448
31 0.994783 0.581417 0.642990 0.187778 0.120590 0.322226 0.315292 0.848420 0.631466 0.927877 ... 0.689750 0.569225 0.209454 0.926524 0.739159 0.023987 0.913384 0.886052 0.728478 0.590927
32 0.454040 0.913367 0.763088 0.917878 0.116524 0.515351 0.015627 0.240662 0.578310 0.506549 ... 0.989989 0.076968 0.518571 0.972219 0.733205 0.598217 0.513824 0.610017 0.065206 0.363980
33 0.801830 0.402936 0.085547 0.748554 0.427546 0.463883 0.902379 0.816046 0.295814 0.959479 ... 0.618385 0.678652 0.041313 0.597345 0.843527 0.724964 0.198188 0.999403 0.769027 0.204517
34 0.105869 0.926904 0.245412 0.230573 0.675308 0.202558 0.151878 0.377364 0.298879 0.808496 ... 0.057346 0.262988 0.363284 0.429321 0.189320 0.452330 0.868304 0.651142 0.873020 0.712429
35 0.193409 0.019434 0.109868 0.004339 0.789232 0.204218 0.218865 0.587106 0.445115 0.386927 ... 0.775689 0.402072 0.860941 0.573424 0.913064 0.127865 0.723009 0.680258 0.451426 0.889079
36 0.230001 0.100422 0.688438 0.831594 0.815913 0.142813 0.741943 0.754265 0.626268 0.048226 ... 0.848366 0.717152 0.453898 0.557210 0.860404 0.922190 0.933695 0.810617 0.800066 0.767754
37 0.707604 0.901610 0.140644 0.009417 0.745643 0.383997 0.005998 0.738917 0.268108 0.972591 ... 0.492394 0.053785 0.135934 0.240740 0.363675 0.515271 0.538818 0.863100 0.334764 0.221060
38 0.227849 0.275190 0.735994 0.251943 0.774193 0.893907 0.380651 0.602345 0.812799 0.826846 ... 0.750576 0.827926 0.517128 0.972679 0.345969 0.371649 0.990429 0.741643 0.147165 0.779047
39 0.408287 0.726112 0.599019 0.399557 0.647511 0.422403 0.069553 0.750626 0.802162 0.978599 ... 0.506200 0.874581 0.231177 0.029876 0.352507 0.194167 0.986697 0.363142 0.191244 0.672595
40 0.070279 0.520130 0.586946 0.171738 0.642893 0.758870 0.191472 0.684346 0.147900 0.269830 ... 0.864472 0.196934 0.174957 0.601770 0.737757 0.053067 0.389799 0.448798 0.455847 0.567200
41 0.892150 0.157280 0.025805 0.180531 0.514688 0.121467 0.207972 0.486247 0.501503 0.505264 ... 0.504418 0.003305 0.118906 0.126078 0.869016 0.038424 0.639921 0.314488 0.446503 0.327203
42 0.066994 0.750233 0.748451 0.404325 0.442776 0.641104 0.697687 0.385261 0.325429 0.797123 ... 0.754794 0.196740 0.298421 0.370713 0.420741 0.444511 0.527007 0.294383 0.325907 0.908197
43 0.821830 0.924825 0.098836 0.658566 0.574558 0.795963 0.588508 0.242464 0.427039 0.966281 ... 0.851965 0.960941 0.391180 0.124206 0.873074 0.947989 0.309699 0.303015 0.127884 0.249931
44 0.663866 0.188455 0.537859 0.623510 0.704454 0.430267 0.728948 0.451012 0.026536 0.861262 ... 0.754363 0.069568 0.759447 0.175694 0.512351 0.988948 0.513522 0.208476 0.954547 0.300497
45 0.705035 0.484753 0.400979 0.549746 0.091355 0.305367 0.757829 0.077044 0.584681 0.724965 ... 0.163371 0.319997 0.041784 0.044992 0.435499 0.210591 0.130503 0.854157 0.268405 0.233800
46 0.148845 0.338137 0.172033 0.295572 0.152926 0.043689 0.861013 0.645503 0.329513 0.899285 ... 0.872663 0.575978 0.198636 0.393568 0.001405 0.801172 0.119428 0.405122 0.892502 0.354516
47 0.262433 0.943306 0.585878 0.476753 0.476021 0.248961 0.033250 0.426974 0.011094 0.025637 ... 0.461629 0.904429 0.429718 0.422534 0.274365 0.450561 0.668339 0.625603 0.253046 0.930823
48 0.040799 0.815473 0.135369 0.648973 0.869085 0.681890 0.914273 0.359228 0.582177 0.155867 ... 0.904846 0.146556 0.711682 0.921989 0.051516 0.121222 0.538834 0.346720 0.578281 0.451195
49 0.660815 0.177575 0.280384 0.277794 0.177575 0.218147 0.479055 0.450827 0.602637 0.761615 ... 0.411548 0.486290 0.780825 0.059796 0.327315 0.061378 0.345981 0.911617 0.618819 0.507479

50 rows × 25 columns

Modify Floating Point Precision

Below we have modified floating-point precision to 2 digits after the decimal point. We can notice from the presentation below that now it only shows 2 digits after the decimal point.

pd.set_option("precision", 2)
df
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 ... Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.18 0.14 0.22 0.34 7.31e-01 0.28 0.38 0.80 0.43 0.88 ... 0.68 0.58 0.91 0.14 0.63 0.74 0.85 0.86 0.33 0.75
1 0.72 0.37 0.89 0.33 9.42e-01 0.29 0.44 0.50 0.78 0.50 ... 0.06 0.22 0.62 0.49 0.36 0.84 0.08 0.59 0.40 0.26
2 0.95 0.80 0.42 0.27 8.98e-01 0.85 0.59 0.65 0.38 0.67 ... 0.02 0.46 0.80 0.88 0.97 0.20 0.94 0.54 0.65 0.12
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
67 0.11 0.18 0.95 0.38 8.88e-01 0.95 0.71 0.62 0.98 0.08 ... 0.71 0.99 0.38 0.09 0.50 0.23 0.47 0.65 0.75 0.63
68 0.51 0.23 0.61 0.61 5.38e-04 0.37 0.41 0.61 0.74 0.19 ... 0.69 0.58 0.75 0.66 0.73 0.28 0.99 0.97 0.83 0.28
69 0.84 0.07 0.49 0.89 3.94e-01 0.58 0.41 0.81 0.67 0.44 ... 0.06 0.83 0.51 0.46 0.22 0.84 0.13 0.11 0.76 0.31

70 rows × 25 columns

Modify DataFrame Representation which Crosses Default Max Rows/Columns

As a part of this section, we have explained how to modify the presentation of the data frame if the number of rows and columns both exceeds set option values. We'll be using large_repr option for it.


  • display.large_repr - This option accepts one of the below strings as input.
    • info - If the option is set to this value and data frame has more rows & columns than default values of max_rows & max_columns then it'll display data frame as information about columns only. It won't display actual data contents. It'll create the same representation as we have got by calling info() method of the data frame.
    • truncate - This default value of the option. If the option is set with this value then it creates truncated rows and columns representation that we have been seeing till now in our examples (with '...' cells).

Below we have explained the usage of large_repr option. We have first set max_rows and max_columns to particular values so that the data frame exceeds them and the value of option large_repr will be used to determine representation.

pd.set_option("max_rows", 50)
pd.set_option("max_columns", 20)

pd.set_option("large_repr", "info")
df
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 70 entries, 0 to 69
Data columns (total 25 columns):
 #   Column    Non-Null Count  Dtype
---  ------    --------------  -----
 0   Column1   70 non-null     float64
 1   Column2   70 non-null     float64
 2   Column3   70 non-null     float64
 3   Column4   70 non-null     float64
 4   Column5   70 non-null     float64
 5   Column6   70 non-null     float64
 6   Column7   70 non-null     float64
 7   Column8   70 non-null     float64
 8   Column9   70 non-null     float64
 9   Column10  70 non-null     float64
 10  Column11  70 non-null     float64
 11  Column12  70 non-null     float64
 12  Column13  70 non-null     float64
 13  Column14  70 non-null     float64
 14  Column15  70 non-null     float64
 15  Column16  70 non-null     float64
 16  Column17  70 non-null     float64
 17  Column18  70 non-null     float64
 18  Column19  70 non-null     float64
 19  Column20  70 non-null     float64
 20  Column21  70 non-null     float64
 21  Column22  70 non-null     float64
 22  Column23  70 non-null     float64
 23  Column24  70 non-null     float64
 24  Column25  70 non-null     float64
dtypes: float64(25)
memory usage: 13.8 KB

Limit DataFrame Info Display Beyond Threshold Columns

As a part of this section, we'll explain how we can limit how many columns details to display when using info() function.


  • display.max_info_columns - This option takes integer value as input. It decides when information about each column is to be displayed when info() function is called. If we set a value greater than the columns of the data frame then info about all columns will be displayed else column’s details will be truncated. The default value is 100 for this option.

Below we have called info() function to display information with default value of max_info_columns option.

df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 70 entries, 0 to 69
Data columns (total 25 columns):
 #   Column    Non-Null Count  Dtype
---  ------    --------------  -----
 0   Column1   70 non-null     float64
 1   Column2   70 non-null     float64
 2   Column3   70 non-null     float64
 3   Column4   70 non-null     float64
 4   Column5   70 non-null     float64
 5   Column6   70 non-null     float64
 6   Column7   70 non-null     float64
 7   Column8   70 non-null     float64
 8   Column9   70 non-null     float64
 9   Column10  70 non-null     float64
 10  Column11  70 non-null     float64
 11  Column12  70 non-null     float64
 12  Column13  70 non-null     float64
 13  Column14  70 non-null     float64
 14  Column15  70 non-null     float64
 15  Column16  70 non-null     float64
 16  Column17  70 non-null     float64
 17  Column18  70 non-null     float64
 18  Column19  70 non-null     float64
 19  Column20  70 non-null     float64
 20  Column21  70 non-null     float64
 21  Column22  70 non-null     float64
 22  Column23  70 non-null     float64
 23  Column24  70 non-null     float64
 24  Column25  70 non-null     float64
dtypes: float64(25)
memory usage: 13.8 KB

Below we have modified max_info_columns to 20 which is less than the number of columns of the data frame hence the presentation of info() method will truncate information about individual columns.

pd.set_option("display.max_info_columns", 20)
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 70 entries, 0 to 69
Columns: 25 entries, Column1 to Column25
dtypes: float64(25)
memory usage: 13.8 KB

Modify DataFrame Info Display to Include/Exclude Null Count

We'll now explain how we can include/exclude details about Null when info() method is called using max_info_rows option.


  • display.max_info_rows - This option accepts integer value. If the value of this option is more than the number of rows in the data frame then a count of Nulls will be displayed for each column in representation created by info() method/ If a value is less than a number of rows then this info will be excluded. The default value of this option is 1690785.

Below we have set max_info_rows to count 100 first which is more than our data frame rows count of 70. Hence it includes information about nulls when info() method is called.

pd.set_option("display.max_info_columns", 25)

pd.set_option("max_info_rows", 100)

df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 70 entries, 0 to 69
Data columns (total 25 columns):
 #   Column    Non-Null Count  Dtype
---  ------    --------------  -----
 0   Column1   70 non-null     float64
 1   Column2   70 non-null     float64
 2   Column3   70 non-null     float64
 3   Column4   70 non-null     float64
 4   Column5   70 non-null     float64
 5   Column6   70 non-null     float64
 6   Column7   70 non-null     float64
 7   Column8   70 non-null     float64
 8   Column9   70 non-null     float64
 9   Column10  70 non-null     float64
 10  Column11  70 non-null     float64
 11  Column12  70 non-null     float64
 12  Column13  70 non-null     float64
 13  Column14  70 non-null     float64
 14  Column15  70 non-null     float64
 15  Column16  70 non-null     float64
 16  Column17  70 non-null     float64
 17  Column18  70 non-null     float64
 18  Column19  70 non-null     float64
 19  Column20  70 non-null     float64
 20  Column21  70 non-null     float64
 21  Column22  70 non-null     float64
 22  Column23  70 non-null     float64
 23  Column24  70 non-null     float64
 24  Column25  70 non-null     float64
dtypes: float64(25)
memory usage: 13.8 KB

Below we have set max_info_rows count to 50 which is less than our data frame rows hence null count information is excluded from representation created by info() method.

pd.set_option("max_info_rows", 50)

df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 70 entries, 0 to 69
Data columns (total 25 columns):
 #   Column    Dtype
---  ------    -----
 0   Column1   float64
 1   Column2   float64
 2   Column3   float64
 3   Column4   float64
 4   Column5   float64
 5   Column6   float64
 6   Column7   float64
 7   Column8   float64
 8   Column9   float64
 9   Column10  float64
 10  Column11  float64
 11  Column12  float64
 12  Column13  float64
 13  Column14  float64
 14  Column15  float64
 15  Column16  float64
 16  Column17  float64
 17  Column18  float64
 18  Column19  float64
 19  Column20  float64
 20  Column21  float64
 21  Column22  float64
 22  Column23  float64
 23  Column24  float64
 24  Column25  float64
dtypes: float64(25)
memory usage: 13.8 KB

Modify Max Column Width

As a part of this section, we'll explain how we can modify columns to truncate extra characters if crosses a certain limit using display.max_colwidth option.


  • display.max_colwidth - This option accepts integer value which let us width of columns. If our data frame cell has values that are more characters than the value of this option then it'll truncate it. The default value of an option is 50.

Below we have first reset large_repr option to truncate so that it displays truncated data frames and not info representation. We have then set the value of max_colwidth option to 10 which will make cell values be truncated which has more than 10 characters.

We have created a new data frame of strings for explanation purposes

pd.set_option("large_repr", "truncate")
pd.set_option("precision", 6)

pd.set_option("max_colwidth", 10)
data = [["RandomValue1", "RandomValue2", "RandomValue3"],
        ["RandomValue4", "RandomValue5", "RandomValue6"],
        ["RandomValue7", "RandomValue8", "RandomValue9"],
        ["RandomValue10", "RandomValue11", "RandomValue12"]]

new_df = pd.DataFrame(data, columns=["Column%d"%(i+1) for i in range(3)])

new_df
Column1 Column2 Column3
0 Random... Random... Random...
1 Random... Random... Random...
2 Random... Random... Random...
3 Random... Random... Random...

Display Float Values Below Threshold as Zero

As a part of this section, we'll explain how we can remove values below a particular threshold float value from the presentation using chop_threshold option.


  • display.chop_threshold - This option takes float value and set all values below it to 0 in data frame presentation. The default value for this parameter is None which makes it ineffective.

Below we have set chop_threshold to 0.5 which will set all values 0.5 in data frame presentation to 0.

pd.set_option("large_repr", "truncate")

pd.set_option("chop_threshold", 0.5)
df
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 ... Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.000000 0.000000 0.000000 0.000000 0.731051 0.000000 0.000000 0.796633 0.000000 0.876371 ... 0.684205 0.577935 0.914046 0.000000 0.632392 0.735557 0.852238 0.856759 0.000000 0.753213
1 0.721353 0.000000 0.894318 0.000000 0.941758 0.000000 0.000000 0.000000 0.779727 0.500529 ... 0.000000 0.000000 0.623476 0.000000 0.000000 0.840696 0.000000 0.593708 0.000000 0.000000
2 0.945869 0.796354 0.000000 0.000000 0.897543 0.849198 0.591911 0.645442 0.000000 0.666719 ... 0.000000 0.000000 0.798625 0.881347 0.967183 0.000000 0.942167 0.540091 0.648999 0.000000
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
67 0.000000 0.000000 0.952482 0.000000 0.888141 0.950874 0.711286 0.624093 0.979744 0.000000 ... 0.714909 0.988277 0.000000 0.000000 0.000000 0.000000 0.000000 0.653704 0.746532 0.632889
68 0.507982 0.000000 0.613693 0.613308 0.000000 0.000000 0.000000 0.611471 0.741501 0.000000 ... 0.688929 0.583748 0.746735 0.655962 0.731675 0.000000 0.988863 0.968679 0.834988 0.000000
69 0.842077 0.000000 0.000000 0.885131 0.000000 0.576739 0.000000 0.805430 0.665720 0.000000 ... 0.000000 0.833661 0.508584 0.000000 0.000000 0.842794 0.000000 0.000000 0.761531 0.000000

70 rows × 25 columns

Option to Display Memory Usage by DataFrame

As a part of this section, we'll explain how we can include/exclude memory usage information from presentations created by info() method using memory_usage option.


  • memory_usage - This option takes boolean value as input. If we set it to True then memory usage information will be included in the presentation of info(). If we set it to False then it will be excluded.

Below we have first set memory_usage to False to exclude it from the presentation and then True again to include it.

pd.set_option("max_info_rows", 1690785)
pd.set_option("max_info_columns", 100)

pd.set_option("memory_usage", False)
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 70 entries, 0 to 69
Data columns (total 25 columns):
 #   Column    Non-Null Count  Dtype
---  ------    --------------  -----
 0   Column1   70 non-null     float64
 1   Column2   70 non-null     float64
 2   Column3   70 non-null     float64
 3   Column4   70 non-null     float64
 4   Column5   70 non-null     float64
 5   Column6   70 non-null     float64
 6   Column7   70 non-null     float64
 7   Column8   70 non-null     float64
 8   Column9   70 non-null     float64
 9   Column10  70 non-null     float64
 10  Column11  70 non-null     float64
 11  Column12  70 non-null     float64
 12  Column13  70 non-null     float64
 13  Column14  70 non-null     float64
 14  Column15  70 non-null     float64
 15  Column16  70 non-null     float64
 16  Column17  70 non-null     float64
 17  Column18  70 non-null     float64
 18  Column19  70 non-null     float64
 19  Column20  70 non-null     float64
 20  Column21  70 non-null     float64
 21  Column22  70 non-null     float64
 22  Column23  70 non-null     float64
 23  Column24  70 non-null     float64
 24  Column25  70 non-null     float64
dtypes: float64(25)
pd.set_option("memory_usage", True)
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 70 entries, 0 to 69
Data columns (total 25 columns):
 #   Column    Non-Null Count  Dtype
---  ------    --------------  -----
 0   Column1   70 non-null     float64
 1   Column2   70 non-null     float64
 2   Column3   70 non-null     float64
 3   Column4   70 non-null     float64
 4   Column5   70 non-null     float64
 5   Column6   70 non-null     float64
 6   Column7   70 non-null     float64
 7   Column8   70 non-null     float64
 8   Column9   70 non-null     float64
 9   Column10  70 non-null     float64
 10  Column11  70 non-null     float64
 11  Column12  70 non-null     float64
 12  Column13  70 non-null     float64
 13  Column14  70 non-null     float64
 14  Column15  70 non-null     float64
 15  Column16  70 non-null     float64
 16  Column17  70 non-null     float64
 17  Column18  70 non-null     float64
 18  Column19  70 non-null     float64
 19  Column20  70 non-null     float64
 20  Column21  70 non-null     float64
 21  Column22  70 non-null     float64
 22  Column23  70 non-null     float64
 23  Column24  70 non-null     float64
 24  Column25  70 non-null     float64
dtypes: float64(25)
memory usage: 13.8 KB

Display/Hide Dimensions of DataFrame

As a part of this section, we'll explain how we can include/exclude data frame dimension details from a presentation created by info() method using show_dimensions option.


  • show_dimensions - This option takes boolean value as input and works exactly like memoery_usage parameter. If we set it to True then dimension details will be included in the presentation of info(). If we set it to False then it will be excluded.

pd.set_option("show_dimensions", False)
df
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 ... Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.000000 0.000000 0.000000 0.000000 0.731051 0.000000 0.000000 0.796633 0.000000 0.876371 ... 0.684205 0.577935 0.914046 0.000000 0.632392 0.735557 0.852238 0.856759 0.000000 0.753213
1 0.721353 0.000000 0.894318 0.000000 0.941758 0.000000 0.000000 0.000000 0.779727 0.500529 ... 0.000000 0.000000 0.623476 0.000000 0.000000 0.840696 0.000000 0.593708 0.000000 0.000000
2 0.945869 0.796354 0.000000 0.000000 0.897543 0.849198 0.591911 0.645442 0.000000 0.666719 ... 0.000000 0.000000 0.798625 0.881347 0.967183 0.000000 0.942167 0.540091 0.648999 0.000000
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
67 0.000000 0.000000 0.952482 0.000000 0.888141 0.950874 0.711286 0.624093 0.979744 0.000000 ... 0.714909 0.988277 0.000000 0.000000 0.000000 0.000000 0.000000 0.653704 0.746532 0.632889
68 0.507982 0.000000 0.613693 0.613308 0.000000 0.000000 0.000000 0.611471 0.741501 0.000000 ... 0.688929 0.583748 0.746735 0.655962 0.731675 0.000000 0.988863 0.968679 0.834988 0.000000
69 0.842077 0.000000 0.000000 0.885131 0.000000 0.576739 0.000000 0.805430 0.665720 0.000000 ... 0.000000 0.833661 0.508584 0.000000 0.000000 0.842794 0.000000 0.000000 0.761531 0.000000

Modify Justification of Column Header

As a part of this section, we'll explain how we can justify column headers in the data frame using colheader_justify option.


  • display.colheader_justify - This options takes value right to specify that column headers should be right justified or left to left justify.

Below we have explained the usage of the option.

pd.set_option("chop_threshold", None)

pd.set_option("colheader_justify", "right")
data=np.random.random((5,5))

new_df = pd.DataFrame(data, columns=["A","B", "C", "D", "E"])

display(new_df)
A B C D E
0 0.188007 0.939670 0.107412 0.078388 0.653300
1 0.402137 0.553279 0.043038 0.535036 0.452607
2 0.637342 0.172271 0.274942 0.901690 0.612657
3 0.184165 0.845850 0.479533 0.921625 0.712419
4 0.030998 0.792873 0.666201 0.990978 0.201594

Reset Option to Default Behavior

As a part of this section, we'll explain how we can reset the option to default value using reset_option() method.


  • reset_option(pattern) - This method takes full option name or partial option name like other option modification methods that we explored earlier. It then resets the value of that option to the default value.

Below we have modified the default value of option max_columns and then reset it back to the default value.

print("Display Max Column Default Value : {}".format(pd.get_option("display.max_columns")))

pd.options.display.max_columns = 25

print("Display Max Column New     Value : {}".format(pd.get_option("display.max_columns")))

pd.reset_option("display.max_columns")

print("Display Max Column Reset   Value : {}".format(pd.get_option("display.max_columns")))
Display Max Column Default Value : 20
Display Max Column New     Value : 25
Display Max Column Reset   Value : 20

Temporary Modify Options within Context

There can be situations then we want to modify options only for a particular section of our code rather than making global changes. We can do that by using option_context() method of pandas as a context manager (with statement). It let us modify options for a particular section of our code and then resets options back to default values.


  • option_context(args) - This method accepts a list of options followed by their values that we want to modify for a particular context of our code. It only resets this value for the context. Once the context is over, the values will be reset back to default or whatever value was set outside of context (with statement).

Below we have set max_columns and max_rows option for particular section of our code. When we display the dataframe in that section, it displays all columns because we have modified max columns to 25 for that section of code. The values of options outside that section will be default or whatever was set outside of it.

print("Max Columns Outside Context : {}".format(pd.options.display.max_columns))
print("Max Rows    Outside Context : {}".format(pd.options.display.max_rows))

with pd.option_context("display.max_columns", 25, "display.max_rows", 50):
    print("Max Columns Inside  Context : {}".format(pd.options.display.max_columns))
    print("Max Rows    Inside  Context : {}".format(pd.options.display.max_rows))

    display(df)
Max Columns Outside Context : 20
Max Rows    Outside Context : 50
Max Columns Inside  Context : 25
Max Rows    Inside  Context : 50
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10 Column11 Column12 Column13 Column14 Column15 Column16 Column17 Column18 Column19 Column20 Column21 Column22 Column23 Column24 Column25
0 0.184588 0.144494 0.220359 0.343531 0.731051 0.275833 0.381695 0.796633 0.430259 0.876371 0.976755 0.472714 0.167219 0.380681 0.041427 0.684205 0.577935 0.914046 0.136737 0.632392 0.735557 0.852238 0.856759 0.330864 0.753213
1 0.721353 0.366603 0.894318 0.331279 0.941758 0.285863 0.444992 0.498363 0.779727 0.500529 0.756796 0.113007 0.766567 0.976172 0.070463 0.059706 0.217124 0.623476 0.488818 0.358538 0.840696 0.084952 0.593708 0.404494 0.263645
2 0.945869 0.796354 0.423261 0.273475 0.897543 0.849198 0.591911 0.645442 0.379223 0.666719 0.751458 0.651565 0.068140 0.082032 0.818177 0.020077 0.457074 0.798625 0.881347 0.967183 0.198972 0.942167 0.540091 0.648999 0.123289
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
67 0.113022 0.184803 0.952482 0.381586 0.888141 0.950874 0.711286 0.624093 0.979744 0.076829 0.425918 0.915160 0.702043 0.753486 0.912746 0.714909 0.988277 0.382353 0.086678 0.495954 0.230577 0.465815 0.653704 0.746532 0.632889
68 0.507982 0.225934 0.613693 0.613308 0.000538 0.366097 0.413763 0.611471 0.741501 0.188538 0.862204 0.857585 0.681589 0.597970 0.112004 0.688929 0.583748 0.746735 0.655962 0.731675 0.276506 0.988863 0.968679 0.834988 0.280728
69 0.842077 0.073247 0.493358 0.885131 0.394345 0.576739 0.411708 0.805430 0.665720 0.442630 0.731525 0.024916 0.764527 0.081460 0.322126 0.064674 0.833661 0.508584 0.457716 0.221259 0.842794 0.129998 0.114098 0.761531 0.305855

This ends our small tutorial explaining how we can work with pandas options. Please feel free to let us know your views in the comments section.

References

Sunny Solanki  Sunny Solanki

YouTube Subscribe Comfortable Learning through Video Tutorials?

If you are more comfortable learning through video tutorials then we would recommend that you subscribe to our YouTube channel.

Need Help Stuck Somewhere? Need Help with Coding? Have Doubts About the Topic/Code?

When going through coding examples, it's quite common to have doubts and errors.

If you have doubts about some code examples or are stuck somewhere when trying our code, send us an email at coderzcolumn07@gmail.com. We'll help you or point you in the direction where you can find a solution to your problem.

You can even send us a mail if you are trying something new and need guidance regarding coding. We'll try to respond as soon as possible.

Share Views Want to Share Your Views? Have Any Suggestions?

If you want to

  • provide some suggestions on topic
  • share your views
  • include some details in tutorial
  • suggest some new topics on which we should create tutorials/blogs
Please feel free to contact us at coderzcolumn07@gmail.com. We appreciate and value your feedbacks. You can also support us with a small contribution by clicking DONATE.


Subscribe to Our YouTube Channel

YouTube SubScribe

Newsletter Subscription