title: Python equivalent to dplyr's ifelse
body: <p>I'm converting code from R to Python and am looking for some help with mutating a new column based on other columns, using <code>dfply</code> syntax/piping</p>
  
  <p>In this example, I want to subtract 2 from <code>col1</code> if <code>col2</code> is 'c', otherwise add 4</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  from dfply import *
  
  col1 = [1,2,3,4,5]
  col2 = ['a', 'b', 'c', 'd', 'e']
  
  df = pd.DataFrame(data = {'col1': col1, 'col2': col2})
  </code></pre>
  
  <p>in R I would do:</p>
  
  <pre><code>df_new &lt;- df %&gt;% 
    mutate(newCol = ifelse(col2 == 'c', col1 - 2, col1 + 4))
  </code></pre>
  
  <p>but Python doesn't seem to like this:</p>
  
  <pre><code>new_df = (df &gt;&gt;
      mutate(newCol = np.where(X.col2 == 'c', X.col1 - 2, X.col1 + 4)))
  </code></pre>
  
  <p>I get an error of "invalid __array_struct__"</p>
  
  <p>Note that this works fine:</p>
  
  <pre><code>new_df = (df &gt;&gt;
      mutate(newCol = X.col1 - 2))
  </code></pre>