title: Conditioning for differences pandas dataframe columns based on third column
body: <p>In the following pandas dataframe, how do I obtain a third column 'spread' based on 'acqDis_nondrv',</p>
  <pre><code>acqDis_nondrv  Close nondrvPrice
             D      8      32.015
             A      16     5.729
             D      20     20.00
             A      16     5.729
             A      16     5.729
  </code></pre>
  <p>Expected Outcome</p>
  <pre><code>    acqDis_nondrv     Close  nondrvPrice  spread
                 D      8      32.015.      24.015     
                 A      16     5.729        10.271
                 D      20     20.00        0
                 A      16     5.729        10.271
                 A      16     5.729.       10.271
  </code></pre>
  <p>Essentially what I am trying to accomplish is get the differences between '<code>Close</code>' and '
  <code>nondrvPrice</code>' based on <code>acqDis_nondrv</code> column.</p>
  <p>I tried</p>
  <pre><code>df['spread']=df['Close']-df['nondrvPrice']
  </code></pre>
  <p>how do I add the conditions for my requirements?</p>
  <ul>
  <li><p>if acqDis_nondrv == 'A' then df['Close']-df['nondrvPrice'],</p>
  </li>
  <li><p>if acqDis_nondrv == 'D' df['nondrvPrice']-df['Close']</p>
  </li>
  </ul>