title: How to make an average from DB data? TypeError: unsupported operand type(s) for /: 'Decimal' and 'float'
body: <p>I'm looping through some data returned from a MySQL database. I don't have control over the data formats in the DB (or anything else related to the data). </p>
  
  <p>I want to create a mean (average) of the returned values. The values look like this when a DB row is printed in Python:</p>
  
  <pre><code>('username', Decimal('8.4600'), Decimal('10.4300'), Decimal('9.48600000'), Decimal('1.9700'), 5L)
  </code></pre>
  
  <p>My code is basically just this:</p>
  
  <pre><code>import numpy
  #make a list in a loop from the DB data rows
  avg = numpy.mean(list)
  </code></pre>
  
  <p>My error is:</p>
  
  <p>TypeError: unsupported operand type(s) for /: 'Decimal' and 'float'</p>
  
  <p>Obviously, I need to convert the types. I would prefer to convert DB Decimal type to a common Python type (such as float). I'm not working with money; the numbers are appropriately represented as floats.</p>
  
  <p>What's the best way to handle this?</p>