Difference vectorized function and the .apply method

Screen Link: https://app.dataquest.io/m/345/transforming-data-with-pandas/6/apply-functions-along-an-axis-using-the-apply-method-continued

Question on below’s explanation during the course:

What is the difference between .apply() and a vectorized function? Can you give an example of a vectorized function?

Hey, Luukvan.

I’m sorry I can’t be of better help. The difference is explained right there:

Recall that pandas uses vectorization , the process of applying operations to whole series at once, to optimize performance. When we use the apply() method, we’re actually looping through rows, so a vectorized method can perform an equivalent task faster than the apply() method.

Can you help us understand what is it that you don’t understand here, so that someone can try to help?

I also recommend you review the screen Understanding Vectorization from the Introduction to NumPy mission.

Hi Bruno, thanks for swift reply. I will reference “Understanding Vectorization”.

1 Like