title: Pandas Dataframe Iterating
body: <p>long time listener first time caller. I'm using Python 2.7 on OS 10.9.</p>
  
  <p>I have two .csv files: one a list of interesting genes and one a master list of ~17,000 genes with 4 associated columns of metrics (floats).  I created a master dataframe (keys are gene names) using pandas and passed it a list of my interesting genes using .loc.  My new_df is a resulting data frame from that iterative process. Admittedly, there is probably a more idiomatic way of doing this (i.e merging a pandas series with dataframe).</p>
  
  <p>Using new_df I would like resample the master_df searching for and binning genes that are similar.  I'm looking for genes whose values are within 5% of my interesting gene's values in each the four columns.  When I find a match, it gets binned under the correct key in my new_df.  Is there a pandas way to accomplish this with hierarchical indexing?  Or perhaps this a task for a new dictionary? 
  Thanks for your guidance!</p>
  
  <p>Here is a snippet of code:</p>
  
  <pre><code>import pandas as pd
  
  def list_getter():
      gene_list = []
      with open('experiment.csv', 'U') as f:
          for i in f:
              gene_list.append(i)
          gene_list[:] = [line.rstrip('\n') for line in gene_list]
          return gene_list
          f.close()
  
  def master_df():
      master_df = pd.read_csv('Gene_Metrics_to_Consider.csv', index_col=0) #index by gene name
  
  def gene_find(gene_list, df2):
      '''takes list of genes, returns new dataframe with extracted metrics'''
      for i in gene_list: #find genes and associated metrics
          new_df = df2.loc[gene_list] #NaN returned for genes not found
      return new_df
  
  def bin_similar_genes():
  </code></pre>