From the course: Advanced Pandas

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Apply/Map/Applymap

Apply/Map/Applymap

From the course: Advanced Pandas

Start my 1-month free trial

Apply/Map/Applymap

- [Instructor] Python functions can be applied with great impact in pandas to alter data in your data frames. Thankfully, you don't have to create a for-loop to iterate through every row in your data to do this. In fact, it's not encouraged if you can help it. Pandas has frameworks that are simpler and more performance known as Apply, Map, and Applymap. Let's dig in. We'll start off with the data frame, including revenue and cost data for certain regions, teams, and squad. Now let's say you want to determine whether each squad was returning a profit or not. This means revenue exceeds their loss. This is an excellent application for Apply. Apply allows you to harness functions to alter values along an access in your data frame, or in your series. We'll save a bit more time by using a Lambda function. This allows you to create the function in the Apply statement without having had to create it in advance. Our Lambda…

Contents