title: pandas match date in one df with timeframe in another, then groupby-sum
body: <p>I have two dataframes, <code>test1</code> and <code>test2</code>. For each <code>ID</code> value in <code>test2</code>, I want to check the <code>date</code> in <code>test2</code> and compare it to the date ranges for that same <code>ID</code> value in <code>test1</code>. If any of the <code>date</code>'s in <code>test2</code> are within a date range in <code>test1</code>, sum the <code>amount</code> column and assign that sum as an additional column in <code>test1</code>. </p>
  
  <p>Output:</p>
  
  <p>So the new <code>test1</code> df will have a column <code>amount_sum</code> which is the sum of all amounts in <code>test2</code> where the <code>date</code> is within the date range of <code>test1</code> - <strong>for that <code>ID</code></strong></p>
  
  <pre><code>import random
  import string
  
  test1 = pd.DataFrame({
      'ID':[''.join(random.choice(string.ascii_letters[0:4]) for _ in range(3)) for n in range(100)],
      'date1':[pd.to_datetime(random.choice(['01-01-2018','05-01-2018','06-01-2018','08-01-2018','09-01-2018'])) + pd.DateOffset(int(np.random.randint(0, 100, 1))) for n in range(100)],
      'date2':[pd.to_datetime(random.choice(['01-01-2018','05-01-2018','06-01-2018','08-01-2018','09-01-2018'])) + pd.DateOffset(int(np.random.randint(101, 200, 1))) for n in range(100)]
  })
  
  test2 = pd.DataFrame({
      'ID':[''.join(random.choice(string.ascii_letters[0:4]) for _ in range(3)) for n in range(100)],
      'amount':[random.choice([1,2,3,5,10]) for n in range(100)],
      'date':[pd.to_datetime(random.choice(['01-01-2018','05-01-2018','06-01-2018','08-01-2018','09-01-2018'])) + pd.DateOffset(int(np.random.randint(0, 100, 1))) for n in range(100)]
  })
  </code></pre>