title: Looping over a MultiIndex in pandas
body: <p>I have a MultiIndexed DataFrame df1, and would like to loop over it in such a way as to in each instance of the loop have a DataFrame with a regular non-hierarchical index which is the subset of df1 corresponding to the outer index entries. I.e., if i have:</p>
  
  <p><img src="https://i.stack.imgur.com/TMWyW.png" alt="FirstTable"></p>
  
  <p>I want to get </p>
  
  <p><img src="https://i.stack.imgur.com/qtJol.png" alt="SecondTable"></p>
  
  <p>and subsequently C1, C2, etc. I also don't know what the names of these will actually be (C1, etc., just being placeholders here), so would just like to loop over the number of C<sub>i</sub> values I have. </p>
  
  <p>I have been stumbling around with <code>iterrows</code> and various loops and not getting any tangible results and don't really know how to proceed. I feel like a simple solution should exist but couldn't find anything that looked helpful in the documentation, probably due to my own lack of understanding.</p>