• 1 Post
  • 53 Comments
Joined 8 months ago
cake
Cake day: October 26th, 2023

help-circle






  • In that case you can iterate over the rows instead of using apply()

    Test it out and see if it’s more efficient.

    Also, you can improve performance by only passing the required columns to apply()

    df['c'] = df[['a','b']].apply(function, axis=1)
    

    Actually this seems like a better solution for you.

    Here’s another approach, I like this one more because it is a closer match to the problem you described.

    Check the result_type=expand argument for df.apply()