title: iterate through rows on condition pandas python
body: <p>I have an excel table that i read in by   data = pd.read_excel('..data.xlsx')</p>
  
  <pre><code>Block   Concentration   Name    Replicate   Value
  1            100          A          1        1446
  1            100          A          2        25
  1            100          A          3        12
  1            33           A          1        111
  1            33           A          2        222
  1            33           A          3        1234
  ...
  1            0            C          3         86
  ..
  2            100          A          1        634
  2            100          A          2        93
  2            100          A          3        287
  2            33           A          1        97234
  2            33           A          2        1222
  2            33           A          3        456  
  ...  
  2            0            D          3         9800
  ...
  ...
  
  24           0            E         3           93948
  </code></pre>
  
  <p>There are  24 blocks, 4 types of concentrations and many names. There are three replicates for each  'Block|Concentration|Name'   combo, which points to unique 'Value' numbers.</p>
  
  <p>I created a dictionary  'd'  with hashes of :</p>
  
  <pre><code> hash{Block|Concentration|Name|Replicate} -&gt; value 
  </code></pre>
  
  <p>pseudo code:</p>
  
  <pre><code> for block 1-&gt; 24:
       for each concentration:
            print (concentration)
            for each  name:
                 for replicate 1-&gt; 3:
                     print  key of hash{Block|Concentration|Name|Replicate} 
  </code></pre>
  
  <p>my code:</p>
  
  <pre><code>for b in data.Block:
     for c in data.Concentration:
      print(c)
      for n in data.Name:
          for r in data.Replicate:
              print(d)
  </code></pre>
  
  <p>the result is a mess, i think it's printing out everything for each loop. </p>
  
  <p>the output structure i have in mind (output doesn't need to be in the format):</p>
  
  <pre><code> Block1         
  Concentration            Name A                  Name B          Name C..   
    100                 1446   25  12          ..   ..    ..        ...
    33                  111    222  1234       ..   ..    ..
    10                  ..                     ..   ..    ..
    0                   ..                     ..   ..    ..
  
  
  Block2         
  Concentration            Name A                  Name B          Name C..   
    100                 634   93  287          ..   ..    ..        ...
    33                  97234 1222 456         ..   ..    ..
    10                  ..                     ..   ..    ..
    0                   ..                     ..   ..    ..
  
  ..
  ..
  ..
  Block 24 ...
  </code></pre>