1

When I print a DataFrame it displays the dimensions of the object (n rows by k columns) at the bottom of the printout. So, for example:

import pandas as pd
df = pd.DataFrame({"A": [10,20,30,40,50], "B": [20, 30, 10, 40, 50], "C": [32, 234, 23, 23, 42523]})

print(df)

will display:

    A   B      C
0  10  20     32
1  20  30    234
2  30  10     23
3  40  40     23
4  50  50  42523

[5 rows x 3 columns]

Is there a way to turn off the display of that final line [5 rows x 3 columns]?

1 Answer 1

2

Yes! Use pd.options.display.show_dimensions = False:

Here is the original repr:

In [118]: df
Out[118]: 
    A   B      C
0  10  20     32
1  20  30    234
2  30  10     23
3  40  40     23
4  50  50  42523

[5 rows x 3 columns]

After setting show_dimensions = False:

In [119]: pd.options.display.show_dimensions = False

In [120]: df
Out[120]: 
    A   B      C
0  10  20     32
1  20  30    234
2  30  10     23
3  40  40     23
4  50  50  42523

See the pd.get_option docstring (print(pd.get_option.__doc__) for more on all the options.

Sign up to request clarification or add additional context in comments.

2 Comments

BTW, with the latest pandas, the dimensions are not shown anymore for such small dataframes. They are only shown when the dataframe output is truncated (a lot of rows/columns).
True; I got the dimension to be shown by using pd.options.display.show_dimensions = True.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.