title: Iterate over column values matched value based on another column pandas dataframe
body: <p>This is a followup to</p>
  <p><a href="https://stackoverflow.com/questions/36684013/extract-column-value-based-on-another-column-pandas-dataframe">extract column value based on another column pandas dataframe</a></p>
  <p>I have more than one row that matches the column value and want to know how to iterate to efficiently retrieve each value when there are multiple matches.</p>
  <p>Dataframe is</p>
  <pre><code>A  B
  p1 1
  p1 2
  p3 3
  p2 4
  p4 3
  p5 5
  p6 2
  p7 5
  ... around 10000 rows
  </code></pre>
  <p>The below will always pick p3</p>
  <pre><code>df.loc[df['B'] == 3, 'A'].iloc[0]
  </code></pre>
  <p>So I tried to iterate like</p>
  <pre><code> if(len(df.loc[df['B'] == 3, 'A'])) &gt; 1:
                          for i in range(0,len(df.loc[df['B'] == 3, 'A']))-1):
                              print(i,df.loc[df['B'] == 3, 'A'].iloc[i])))
  </code></pre>
  <p>And it prints</p>
  <pre><code>0 p3
  1 p4
  </code></pre>
  <p>for all matching values</p>
  <p>However is there a more efficient way to do this?</p>