title: Replacing Values by multiple conditions
body: <p>I am trying to replace the values of a Dataframe.</p>
  <p>The DataFrame</p>
  <pre><code>data =[[&quot;China&quot;, 1436323776],[&quot;Brazil&quot;, 212559417],[&quot;Germany&quot;, 83992949],[&quot;Egypt&quot;, 102334404],[&quot;Chile&quot;, 19116201],[&quot;Australia&quot;, 25499884],[&quot;Venezuela&quot;, 28435940],[&quot;Netherlands&quot;, 17915568],[&quot;Belgium&quot;, 11589623]]
  
  df = pd.DataFrame(data, columns = [&quot;Country&quot;, &quot;Population&quot;])
  
  
  
      Country Population
  0   China       1436323776
  1   Brazil      212559417
  2   Germany     83992949
  3   Egypt       102334404
  4   Chile       19116201
  5   Australia   25499884
  6   Venezuela   28435940
  7   Netherlands 17915568
  8   Belgium     11589623
  </code></pre>
  <p>What i tried is the following:</p>
  <pre><code>df.loc[df[&quot;Population&quot;] &gt;= 100000000, &quot;Population&quot;] = &quot;large&quot;
  df.loc[(df[&quot;Population&quot;] &gt;= 20000000) &amp; (df[&quot;Population&quot;] &lt; 100000000), &quot;Population&quot;] = &quot;medium&quot;
  df.loc[df[&quot;Population&quot;] &lt; 20000000, &quot;Population&quot;] = &quot;small&quot;
  </code></pre>
  <p>Which works fine if i only run 1 line of it by itself, but when i try to let it run one after another, i get an error since now, not every cell has an int anymore, but also a String, and it cant compare str and int ( obviously). As seen here:</p>
  <pre><code>Country Population
  0   China       large
  1   Brazil      large
  2   Germany     83992949
  3   Egypt       large
  4   Chile       19116201
  5   Australia   25499884
  6   Venezuela   28435940
  7   Netherlands 17915568
  8   Belgium     11589623
  </code></pre>
  <p>So i might have to iterate over each line, check my 3 conditions and then change the value, but i dont know how to do that.</p>
  <p>Thanks for your help.</p>