In this article, we’ll see how we can display a DataFrame in the form of a table with borders around rows and columns. It’s necessary to display the DataFrame in the form of a table as it helps in proper and easy visualization of the data. Now, let’s look at a few ways with the help of examples in which we can achieve this.
Example 1 : One way to display a dataframe in the form of a table is by using the
display() function of
Example 2: In this example we’ll use
DataFrame.style. It returns a Styler object, which has useful methods for formatting and displaying DataFrames.
Example 3 : Using
DataFrame.style we can also add different styles to our dataframe table. Like, in this example we’ll display all the values greater than 90 using the blue colour and rest with black. To achieve this we’ll use
DataFrame.style.applymap() to traverse through all the values of the table and apply the style.
Example 4 :We can also use a library called tabulate for this purpose. It is a library which contains different styles in which dataframes can be displayed. In this example we’ll use the
Below are all the styles that you can use :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Display the Pandas DataFrame in table style and border around the table and not around the rows
- Display the Pandas DataFrame in Heatmap style
- How to widen output display to see more columns in Pandas dataframe?
- How to display bar charts in Pandas dataframe on specified columns?
- Python | Pandas DataFrame.fillna() to replace Null values in dataframe
- Pandas Dataframe.to_numpy() - Convert dataframe to Numpy array
- Convert given Pandas series into a dataframe with its index as another column on the dataframe
- How to Convert Wide Dataframe to Tidy Dataframe with Pandas stack()?
- Read SQL database table into a Pandas DataFrame using SQLAlchemy
- How to render Pandas DataFrame as HTML Table?
- Display all the Sundays of given year using Pandas in Python
- Create a Pandas TimeSeries to display all the Sundays of given year
- Create and display a one-dimensional array-like object using Pandas in Python
- How to display most frequent value in a Pandas series?
- How to display the days of the week for a particular year using Pandas?
- How to get column names in Pandas dataframe
- Python | Pandas DataFrame.reset_index()
- Python | Pandas dataframe.notna()
- Python | Pandas Dataframe.duplicated()
- How to Remove repetitive characters from words of the given Pandas DataFrame using Regex?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.