In the real world, data is huge so is the dataset. While importing a dataset and converting it into DataFrame, the default printing method does not print the entire DataFrame. It compresses the rows and columns. In this article, we are going to learn how to pretty-print the entire DataFrame?
Pandas have the set_options() method which allows us to set different properties according to our requirements and pretty print the entire Dataframe. Below are some pretty print options.
- display.max_columns: It defines the total number of columns to be printed. If None is passed as an argument, all columns would be printed.
- display.max_rows: It defines the total number of rows that need to be printed. If None is passed as an argument all rows would be printed.
- display.width: It is also an important option that defines the width of the display. If set to None, pandas will correctly auto-detect the width.
To work with Python Pandas, we need to import the pandas library. Below is the syntax,
import pandas as pd
Example:
Output:
Hence, by setting different options using the set_options() method, we are now able to see all the columns of our DataFrame including 'Profession' and 'Title'.
need an explanation for this answer? contact us directly to get an explanation for this answer