I have a pandas dataframe 'df' with two columns 'A' and 'B', I have a function with two arguments
def myfunction(B, A):
and I would like to apply it line by line to df using the "apply" function
df['C'] = df['B'].apply(myfunction, args=(df['A'],))
but i get an error
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
What happens here, it seems that df ['A'] is like a whole series! not just a row entry from this series, if required.
source share