title: How to split a dataframe by unique groups and save to a csv
body: <p>I have a pandas dataframe I would like to iterate over. A simplified example of my dataframe:</p>
  <pre><code>chr    start    end    Gene    Value   MoreData
  chr1    123    123    HAPPY    41.1    3.4
  chr1    125    129    HAPPY    45.9    4.5
  chr1    140    145    HAPPY    39.3   4.1
  chr1    342    355    SAD    34.2    9.0
  chr1    360    361    SAD    44.3    8.1
  chr1    390    399    SAD    29.0   7.2
  chr1    400    411    SAD    35.6   6.5
  chr1    462    470    LEG    20.0    2.7
  </code></pre>
  <p>I would like to iterate over each unique gene and create a new file named:</p>
  <pre><code>for Gene in df: ## this is where I need the most help
  
      OutFileName = Gene+&quot;.pdf&quot;
  </code></pre>
  <p>For the above example I should get three iterations with 3 outfiles and 3 dataframes:</p>
  <pre><code># HAPPY.pdf
  chr1    123    123    HAPPY    41.1    3.4 
  chr1    125    129    HAPPY    45.9    4.5 
  chr1    140    145    HAPPY    39.3   4.1
  
  # SAD.pdf
  chr1    342    355    SAD    34.2    9.0 
  chr1    360    361    SAD  44.3    8.1 
  chr1    390    399    SAD    29.0   7.2 
  chr1    400    411    SAD    35.6   6.5
  
  # Leg.pdf
  chr1    462    470    LEG    20.0    2.7
  </code></pre>
  <p>The resulting data frame contents split up by chunks will be sent to another function that will perform the analysis and return the contents to be written to file.</p>