title: For loop over subsetted pandas dataframe
body: <p>I am trying to iteratively create subsets of a dataframe. A toy example:</p>
  
  <pre><code>In:
  
     A  B  participant  
  0  1  3            1          
  1  2  4            1         
  2  5  8            2          
  3  4  9            2
  4  3  7            3
  </code></pre>
  
  <p>(The conditional statement thanks to the commenter below)</p>
  
  <pre><code>for p in df:
      subset = df[df['participant'] == p].loc[: , 'A']
  </code></pre>
  
  <p>The desired outcome is:</p>
  
  <pre><code>   A  participant  
  0  1            1          
  1  2            1
  
     A  participant  
  0  5            2          
  1  4            2   
  </code></pre>
  
  <p>etc.</p>
  
  <p>But the for loop makes a subset by row, not by participant. How to get subsets per participant?  </p>
  
  <p>original attempt:</p>
  
  <pre><code>for p in df:
      p.pressure = df[(:, 'pressure') &amp; (df['participant'] == p)]
  </code></pre>