In the real world, data is huge so is the dataset. While importing a dataset and converting it into DataFrame, if the number of columns is large, the default printing method does not print the entire columns. It compresses the rows and columns. In this article, we are going to learn how to expand the output display to see all the columns of DataFrame.
We can achieve this task with the help of pandas.DataFrame.set_options() function. The set_options() method allows us to set different properties according to our requirements. display.max_columns() defines the total number of columns to be printed. If None is passed as an argument, all columns would be printed.
To work with MultiIndex in Python Pandas, we need to import the pandas library. Below is the syntax,
import pandas as pd
Let us understand with the help of an example.
Output:
Here, we have defined 20 columns but not all the columns are printed, to overcome this problem, we will use the set_options('display.max_columns') method.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer