title: percentage variation pandas dataframe
body: <p>I  a this data frame code:</p>
  <pre><code>analytics = q1.groupby(['Year','YearMonth','glnumber','nom'])[['amount']].sum().reset_index()
  #add previous sales to the next row
  analytics['prev_$'] = analytics['amount'].shift(1)
  #drop the null values and calculate the difference
  analytics = analytics.dropna()
  analytics['diff'] = (analytics['amount'] - analytics['prev_$'])
  analytics = analytics.drop(['prev_$'],
    axis='columns')
  </code></pre>
  <p>I'm trying to calculate percentage of variation by dividing analytics['prev_$'] by analytics['amount']</p>
  <p>this is my code:</p>
  <pre><code>analytics['Perc_diff'] = analytics.apply(0 if analytics['amount'] == 0 else divide(analytics['diff'], analytics['amount']))
  </code></pre>
  <p>But I've this error:
  ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</p>