title: Python iterate over specific column in csv , and replacing values
body: <p>First sorry for my english ;)</p>
  
  <p>I have a problem regarding a csv file. The file contains a lot of col. with a lot of different features. I want to iterate over the col. host_location to get the entries of each row. For each String which contains ("London" or "london") i want to change the string into an binary. So if the string contains "London" or "london" the entry should be 1 , if not 0.</p>
  
  <p>Im familiar with Java, but Python is new for me. </p>
  
  <p>What i know so far with reference to this problem:</p>
  
  <p>i cant change the csv file directly, i have to read it, change the value and write it back to a new file.</p>
  
  <p>My method so far:  </p>
  
  <pre><code>listings = io.read_csv('../data/playground/neu.csv')
  
  def Change_into_Binaryy():
    listings.loc[listings["host_location"] == ( "London" or 
    "london"),"host_location"] = 1
    listings.to_csv("../data/playground/neu1.csv",index =False)    
  </code></pre>
  
  <p>The code is from another question of stackoverflow, and im really not familiar with Python so far. The problem is that i can only use the equal operator and not something like contains in java.</p>
  
  <p>As a result only the entries with the string "London" or "london" are changed to 1. But there are also entries like "London, Uk" that i want to change</p>
  
  <p>In addition i don't know how i can change the remaining entries to 0 , because i don't know how i can combine the .loc with sth. like a if/else construct</p>
  
  <p>I also tried another solution:</p>
  
  <pre><code>def Change_into_Binary():
  
  for x in  listings['host_location']:
      if "London" or "london" in x:
          x = 1
  
      else:
          x = 0
  
  listings.to_csv("../data/playground/neu1.csv",index =False)
  </code></pre>
  
  <p>But also do not work. In this case the entries are not changed.</p>
  
  <p>Thanks for you answers</p>