title: Python Dataframe - apply function on selected rows and columns
body: <p>I have a dataframe <code>df</code> which has two columns <code>A</code> and <code>B</code>. Some rows have NaN for <code>A</code>. I want to apply a function to rows with <code>NaN</code> in <code>A</code> based on the value in column <code>B</code>.</p>
  <p>I tried something like:</p>
  <pre><code>df.loc[df['A'].isnull(), 'A']=df['B'].apply(lambda x: func(x))
  </code></pre>
  <p>I know it won't work but can't figure out the right way.</p>