title: wrong datatype after using a loop to create a list, then adding it to a dataframe
body: <p>I am new to python and need help with the following problem
  I have  a data frame like</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Employee number</th>
  <th>Income</th>
  <th>Working Years</th>
  <th>etc.</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>01</td>
  <td>2000</td>
  <td>10</td>
  <td>...</td>
  </tr>
  <tr>
  <td>02</td>
  <td>3000</td>
  <td>2</td>
  <td>...</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to compare the wage of an employee to the average wage of their peer group.</p>
  <p>Since I don't have information about their peer group, I used I use Kmodes clustering (based on factors likely to impact wages) to create clusters of employees and used those as the peer group. I'm not sure if this is an appropriate method, but I ended up with a dataframe like</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Employee number</th>
  <th>Income</th>
  <th>Working Years</th>
  <th>Cluster</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>01</td>
  <td>2000</td>
  <td>10</td>
  <td>1</td>
  </tr>
  <tr>
  <td>02</td>
  <td>3000</td>
  <td>2</td>
  <td>0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I then calculated the average income of each of the clusters and subtracted each employee's wage from the appropriate average</p>
  <p>my code is below;</p>
  <pre><code>compare=[]
  
  for w in df['cluster']:
      if w == 0:
          compare.append(1000-df['Income'])
      elif x== 1:
          compare.append(2000-df['Income'])
      elif x== 2:
          compare.append(3000-df['Income'])
  </code></pre>
  <p>I want to add the 'compare' column to my original dataframe, so I can end up with</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Employee number</th>
  <th>Income</th>
  <th>Working Years</th>
  <th>Compare</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>01</td>
  <td>2000</td>
  <td>10</td>
  <td>200</td>
  </tr>
  <tr>
  <td>02</td>
  <td>3000</td>
  <td>2</td>
  <td>-100</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>so I tryed</p>
  <p>df['compare']= compare</p>
  <p>I need the column's datatype to be float, but it's coming out as an object, how can I fix this?</p>
  <p>Thanks!</p>