title: ValueError: The truth value of a DataFrame is ambiguous
body: <p>I have a dataframe that looks like this:</p>
  
  <pre><code>        total   downloaded  avg_rating
  id          
  1        2      2           5.0
  2       12     12           4.5
  3        1      1           5.0
  4        1      1           4.0
  5        0      0           0.0
  </code></pre>
  
  <p>I'm trying to add a new column with the percent difference of two of these columns, but only for columns that do not have a 0 in 'downloaded'.</p>
  
  <p>I'm trying to use a function for this that looks like:</p>
  
  <pre><code>def diff(ratings):
      if ratings[ratings.downloaded &gt; 0]:
          val = (ratings['total'] - ratings['downloaded']) / ratings['downloaded']
      else:
          val = 0
      return val
  
  ratings['Pct Diff'] = diff(ratings)
  </code></pre>
  
  <p>I'm getting an error:</p>
  
  <pre><code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-129-729c09bf14e8&gt; in &lt;module&gt;()
        6     return val
        7 
  ----&gt; 8 ratings['Pct Diff'] = diff(ratings)
  
  &lt;ipython-input-129-729c09bf14e8&gt; in diff(ratings)
        1 def diff(ratings):
  ----&gt; 2     if ratings[ratings.downloaded &gt; 0]:
        3         val = (ratings['total'] - ratings['downloaded']) / 
  ratings['downloaded']
        4     else:
        5         val = 0
  
  ~\Anaconda3\lib\site-packages\pandas\core\generic.py in __nonzero__(self)
      953         raise ValueError("The truth value of a {0} is ambiguous. "
      954                          "Use a.empty, a.bool(), a.item(), a.any() or 
  a.all()."
  --&gt; 955                          .format(self.__class__.__name__))
      956 
      957     __bool__ = __nonzero__
  
  ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
  </code></pre>
  
  <p>Can someone please help me understand what this error means? </p>
  
  <p>Also, would this be a good application for an apply function? Can I use conditions in an apply? How would I use it in this case?</p>