title: Group by Column in Dataframe and create seperate csv for all the group
body: <p>I have a huge CSV file of 100kb  which contains records. Example like below</p>
  
  <pre><code>city         employee
  
  california   jhon
  delhi        kumar
  us           raj
  california   brakers
  us           kroja
  ... 
  </code></pre>
  
  <p>So I want to group them and stored in a separate CSV file</p>
  
  <p>My output result for above example would be</p>
  
  <pre><code>city         employee
  
  california   jhon
  california   brakers
  delhi        kumar
  us           raj
  us           kroja
  </code></pre>
  
  <p>Will I have to like sort/group by the city in the data frame and then have a for loop and iterate through the entire data frame?</p>
  
  <p>And her is my code</p>
  
  <pre><code>New_data=pd.read_csv("citynames.csv",encoding = "ISO-8859-1") 
  Aftergrouping_data=New_data.groupby("city")
  #print(Aftergrouping_data.groups)
  
  for name,group in Aftergrouping_data:
      print(name)
      group.to_csv("aftergrouping.csv".format(name), index=False)
  </code></pre>
  
  <p>The problem is its overriding the values in for loop and displays the last group data. but I want all the grouped data in the file.</p>
  
  <p>Thank you In advance</p>