From the course: Fundamentals of Data Transformation for Data Engineering

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Apply

Apply

- [Instructor] And we're back for the final lesson in our pandas portion of the course. And here we're going to talk about the apply method. And apply is very similar to the last SQL lesson on lambdas, or wasn't the last, but on lambdas and UDFs. So apply is similar. It's a method that, as the name suggests, applies a function along an access of a DataFrame or a series. And commonly, we're going to apply this by row. So this is kind of like custom operations. It's almost a mixture of a UDF, but in Python and pandas speak. So, some notes here about apply that I left for you. The syntax is df.apply, function, and then an axis. So, this is going to apply the function that we specify to the axis that we specify. So 1 applies to each row, 0 applies to each column. The function parameter can be built-in function. It can be a lambda function, which is very similar to what we talked about in SQL. So that was a nice segue. Or a custom function defined by the user. For example, we could create…

Contents