title: Modify Pandas series through For loop
body: <p>I have a Pandas DataFrame with item details. One of the columns is Weight and some values are stored as 200kgs, 120kgs etc in the Weight column.</p>
  
  <p>I want to strip the 'kgs' string so that I can use the values for some calculation. I tried doing the same through a For loop to strip the 'kgs'</p>
  
  <pre><code>item = pd.read_csv('item_data.csv') 
  
  for x in item.Weight:  # item.Weight shows the weights of the items
      if type(x) == str:
          item.Weight = x.strip('kgs')
      else:
          item.Weight =  x
  </code></pre>
  
  <p>The above code strips the 'kgs' but displays the first value for all the rows! </p>
  
  <pre><code>item.Weight = [x.strip('kgs') if type(x)==str else x for x in item.Weight]
  </code></pre>
  
  <p>However, when i do list comprehension, as shown above, it works! Can you please explain why the For loop does not seem to work but the List Comprehension with the same logic works</p>