title: Use dates as indicators to a function from two different dataframes
body: <p>I got two dataframes which looks like the following: </p>
  
  <p>dataframe1</p>
  
  <pre><code>  individual   OpenDate  CloseDate MeanReturn
  1          1 2010-01-04 2010-01-08        NaN
  2          2 2010-01-01 2010-01-08        NaN
  3          3 2010-01-03 2010-01-06        NaN
  4          4 2010-01-02 2010-01-05        NaN
  5          5 2010-01-04 2010-01-06        NaN
  </code></pre>
  
  <p>And
  dataframe2</p>
  
  <pre><code>        Date Return
  1 2010-01-01    532
  2 2010-01-02    645
  3 2010-01-03    213
  4 2010-01-04    567
  5 2010-01-05    986
  6 2010-01-06    123
  7 2010-01-07    567
  8 2010-01-08    654
  </code></pre>
  
  <p>What I need to do is to somehow calculate the MeanReturn for each individual, e.g. for individual 5: MeanReturn = (567+986+123)/3 </p>
  
  <p>My real data consists of over 10,000 individuals with a time-period over 2 years, so it's not something easily done by hand unfortunately. </p>
  
  <p>I have been stuck on this problem for almost two weeks now and it's driving me insane - any suggestions on how to solve it?</p>