TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

A Quick and Easy Guide to Conditional Formatting in Pandas

Zeya LT
8 min readFeb 26, 2022

--

Photo by Small Business Computing

The Pandas library in Python has been predominantly used for data manipulation and analysis, but did you know that Pandas also allows for conditional formatting of DataFrames?

Conditional formatting is a feature that allows you to apply specific formatting to cells that fulfill certain conditions. It is common in spreadsheet applications like Microsoft Excel and it helps to draw viewer’s attention to important data points and values. It also allows you to visually dissect a dataset based on colors, making it easier to work with large datasets.

In this article, I will provide a simple guide on how you can apply conditional formatting on Pandas DataFrames. The codes presented in this article can be found as a notebook at this GitHub repo.

The dataset

In this article, we will be using the built-in Iris dataset from the seaborn package. For simplicity, we will take a random sample of 10 observations.

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Zeya LT
Zeya LT

Written by Zeya LT

Data Scientist @ Grab • Former Police Officer • Master’s in Data Science & Analytics • Mid-Career Switcher • Father of Two

Responses (3)