The "where" Function

Learn how to use the Pandas "where" function.

We'll cover the following

Creating conditional columns

The where function can be used to update the values in a column based on some conditions. The where function evaluates the given condition and then updates the values. When the condition is True, the original values are kept the same. When it’s False, the values are updated using the other parameter.

Consider the grocery we’ve been using. Let’s say we want to increase the prices of products cheaper than $3 by 10 percent. We can perform this operation with the where function as below:

Get hands-on with 1400+ tech skills courses.