8 Commonly used Pandas display options you should know
Pandas tips and tricks to help you get started with Data Analysis
Pandas is one of the most important libraries for Data Manipulation and Analysis. It not only offers data structure & operations for manipulating data but also prints the result in a pretty tabular form with labeled rows and columns.
In most cases, the default settings of Pandas display should work well, but you may want your data to be displayed in some format that other than its default one. Pandas has an options system that allows you to customize display-related options. Display options can be configured using either methods or attributes as follows:
# Use methods
import pandas as pdpd.set_option()
pd.get_option()
# Use attributes, for example display max_rows
pd.option.display.max_rows
In this article, we’ll take a look at the 8 commonly used display options. This article is structured as follows:
- Showing more rows
- Showing more columns
- Setting the max characters to be displayed
- Setting the precision for float columns
- Formating the display for large numbers
- Changing plotting backend
- Configuring the output of info()
- Resetting display options
Please check out the Notebook for source code
For demonstration, we will be using the Titanic dataset available on Kaggle.
1. Showing more rows
By default, Pandas doesn’t want to overrun your display and it will truncate the rows in the middle if the display.max_rows is exceeded. You can find the value by running the following statement:
pd.get_option('display.max_rows')
# pd.options.display.max_rows60
Once the display.max_rows is exceeded, the display.min_rows (It defaults to 5 ) option determines how many rows are shown in the truncated representation. For instance, running df , it displays the first 5 rows, truncates all rows in the…