title: Pandas Date Conditional Calculation
body: <p>I am trying to create a column in Pandas based off of a conditional statement that calculates time between two events.  I was able to work out the day calculation but when plugged into my conditional statement:</p>
  
  <pre><code>def defect_age(df):
      if df['Status'] == 'R':
          return (pd.to_datetime(df['resolved_on'], errors='coerce') 
              - pd.to_datetime(df['submitted_on'])) / np.timedelta64(1, 'D')
      else:
          return 'null'
  </code></pre>
  
  <p>And then later called by the column:</p>
  
  <pre><code>group_df['Age'] = group_df.apply(defect_age(group_df), axis=0)
  </code></pre>
  
  <p>I am getting the following 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>I tried to base mine on the question asked <a href="https://stackoverflow.com/questions/27041724/using-conditional-to-generate-new-column-in-pandas-dataframe">HERE</a>... But I am not having much success. Any help is appreciated!</p>