title: Aggregation based on previous month from eventdate
body: <p>I'm Stuck on a problem it would be great if you could help me :)
  I created a dataframe with pandas:
  looks like that:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>HostName</th>
  <th>Date</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>A</td>
  <td>2021-01-01 12:30</td>
  </tr>
  <tr>
  <td>B</td>
  <td>2021-01-01 12:42</td>
  </tr>
  <tr>
  <td>B</td>
  <td>2021-02-01 12:30</td>
  </tr>
  <tr>
  <td>A</td>
  <td>2021-02-01 12:40</td>
  </tr>
  <tr>
  <td>A</td>
  <td>2021-02-25 12:40</td>
  </tr>
  <tr>
  <td>A</td>
  <td>2021-03-01 12:41</td>
  </tr>
  <tr>
  <td>A</td>
  <td>2021-03-01 12:42</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I try to Aggregat based on the previous month but it's not working.
  the end result should look like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>HostName</th>
  <th>Date</th>
  <th>previous month</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>A</td>
  <td>2021-01-01 12:30</td>
  <td>Nan</td>
  </tr>
  <tr>
  <td>B</td>
  <td>2021-01-01 12:42</td>
  <td>Nan</td>
  </tr>
  <tr>
  <td>B</td>
  <td>2021-02-01 12:30</td>
  <td>1</td>
  </tr>
  <tr>
  <td>A</td>
  <td>2021-02-01 12:40</td>
  <td>Nan</td>
  </tr>
  <tr>
  <td>A</td>
  <td>2021-02-25 12:40</td>
  <td>1</td>
  </tr>
  <tr>
  <td>A</td>
  <td>2021-03-01 12:41</td>
  <td>2</td>
  </tr>
  <tr>
  <td>A</td>
  <td>2021-03-01 12:42</td>
  <td>3</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>for every row Date should look one-month before and Aggregat the number of Hostnames found.
  for example row number 6 count HostName A from 2021-02-01 12:41 to 2021-03-01 12:41</p>
  <p>what I try to do and failed:</p>
  <ol>
  <li>extract the previous month:</li>
  </ol>
  <pre><code> df['Date Before'] = df['Date'] - pd.DateOffset(months=1)
  </code></pre>
  <ol start="2">
  <li>and Aggregate between this month</li>
  </ol>
  <pre><code> df.resample('M', on='Date').HostName.count()
   df.groupby('HostName').resample('M', on='Date Before').HostName.count()
  </code></pre>
  <p>Please Help Me many thanks!!!</p>