Skip to content
Advertisement

pandas, apply with args which are dataframe row entries

I have a pandas dataframe ‘df’ with two columns ‘A’ and ‘B’, I have a function with two arguments

JavaScript

and I would like to apply it row-by-row to df using the ‘apply’ function

JavaScript

but I get the error

JavaScript

whats happening here, it seems it takes df[‘A’] as the whole series! not just the row entry from that series as required.

Advertisement

Answer

I think you need:

JavaScript

Or:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement