pandas, apply with args which are dataframe row entries
<p>I have a pandas dataframe 'df' with two columns 'A' and 'B', I have a function with two arguments</p>

<pre><code>def myfunction(B, A):
    # do something here to get the result
    return result
</code></pre>

<p>and I would like to apply it row-by-row to df using the 'apply' function</p>

<pre><code>df['C'] = df['B'].apply(myfunction, args=(df['A'],))
</code></pre>

<p>but I get the error</p>

<pre><code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
</code></pre>

<p>whats happening here, it seems it takes df['A'] as the whole series! not just the row entry from that series as required.</p>