Show all columns of Pandas DataFrame in Jupyter Notebook
In this article, we will discuss how to show all the columns of a pandas data frame in jupyter notebook.
Pandas have a very handy method called get option(), by this method, we can customize the output screen and work without any inconvenient form of outputs. set_option() used to set the value. This is used to set the maximum number of columns and rows that should be displayed, By setting the max_columns to None or a specified number of column
Syntax: pd.set_option(‘display.max_columns’, None)
If we want to change back to normal, reset_option() is used. It is used to reset one or more options to their default value.
Another common problem that arises while using the categorical data is, we couldn’t see the entire categorical value. Because the maximum column width is less, so the data that covers the column width is displayed. Rest is not displayed
In the above example, you can see that data is not displayed enough. To Solve this we can set the max_colwidth higher.
By applying the function, the maximum column width is set to 3000. All the data get displayed.
When we work with a dataset having more columns or rows, we might find it difficult to see all the columns and rows in the pandas. The pandas by default print some of the first rows and some of the last rows. In the middle, it will omit the data. When we deal with datasets with fewer rows and columns does not affect us. But it is difficult to analyze the data without seeing all the rows and columns in a single time.
We can see that it does not print all the columns instead, it is replaced by(…..).
get_option() – This function is used to get the values,
It helps us display the values such as the maximum number of columns displayed, the maximum number of rows displayed, and the maximum column width.
Let us see how to use them,
The Total number of columns present is 25, and the Maximum number of columns displayed is 20. So it displayed the first 10 columns and last 10 columns and we couldn’t see the rest of the columns. We can solve this by maximizing the column and columns’ width.
Now, we can see all the columns are displayed by changing the column width to 100 and the Number of columns to None.