title: Is there a pythonic way to create various DataFrames iterating over a grouped DataFrame?
body: <p>I am trying to do a for loop to iterate over a column in my merged DataFrame. The column holds 52 different provinces from Spain of which I need a different DataFrame for each. I have tried to use .groupby but it doesn't work.</p>
  <p>My final try was making a while loop and a for inside:</p>
  <ul>
  <li>There are 52 provinces, so the counter goes from 52 to 0</li>
  <li>As the counter goes by, the merged DataFrame has to extract the Province referring to the number within the count and save it to a specific DataFrame with the name of the Province</li>
  </ul>
  <pre><code># Making a while-loop for iterating over the provinces
  counter = (len(merged.Provincia.sort_values(ascending=False).unique())+1)
  while counter &lt;= (len(merged.Provincia.sort_values(ascending=False).unique())+1):
      for x in merged.Provincia.sort_values(ascending=False).unique():
          counter = pd.DataFrame(merged[merged['Provincia'] == x])
      counter -= 1
      if counter == -1:
          break
      #print (counter)
  print('\n','The Loop has ended') 
  
  print(merged.head())
  index      Comunidad Provincia     Date     Alquiler      Venta
  0   3120    Galicia  A Coruña   2006-01-01    5.68      1477.19 
  1   3900    Galicia  A Coruña   2006-02-01    5.68      1477.19 
  2   6136    Galicia  A Coruña   2006-03-01    5.68      1477.19 
  3   676     Galicia  A Coruña   2006-04-01    5.68      1477.19 
  4   6968    Galicia  A Coruña   2006-05-01    5.68      1477.19 
  </code></pre>
  <p>So, the DataFrame holds data for all Spanish Provinces (in example, there are 52 different names for the provinces), I would like to make a loop to save each province into a new dataframe with the name of said province:
  For example for Madrid, it would be:</p>
  <pre><code>Madrid = pd.DataFrame(merged[merged['Provincia'] == 'Madrid'])
  </code></pre>
  <p>I can do this by assigning it to the 52 different provinces within the datafram, but I would like to make it wihint a loop for easier manipulation</p>
  <p>If anyone has a better idea on how to this, all are welcome :)</p>