title: Pandas timeseries data - counting unique values during past 24 hours every 30 minutes
body: <p>I am trying to measure message activity on a forum given the data for each individual message. </p>
  
  <p>To do this, I want to know how many <strong>unique/different</strong> authors have posted messages in the last 24 hours, at every half-hour (9:00, 9:30, 10:00, ...).</p>
  
  <p>I have a <code>pandas DataFrame</code> to record message information. A message has a post number, the time it was posted, and who wrote it. This is some of my data:</p>
  
  <pre><code>&gt;&gt;&gt; # import pandas as pd
  &gt;&gt;&gt; # here df is a pd.DataFrame
  &gt;&gt;&gt; print df.loc[:, ['Message Timestamp','Message Author']]
  
   Post#            Message Timestamp     Message Author
  239257    2017-06-09 14:45:46-04:00   JTTLJTTLFBVTNJDF
  239258    2017-06-09 14:09:51-04:00        Tvpfrnpvb22
  239259    2017-06-09 13:54:13-04:00          Hpzb Tbxb
  239260    2017-06-09 13:45:37-04:00      TbnFrbnTrbdfr
  239261    2017-06-09 13:28:55-04:00   JTTLJTTLFBVTNJDF
  239262    2017-06-09 13:20:23-04:00          njlftlj84
  239263    2017-06-09 13:19:59-04:00      TbnFrbnTrbdfr
  239264    2017-06-09 13:19:23-04:00   Vjtb Npvb Ttpdlt
  239265    2017-06-09 13:15:03-04:00          njlftlj84
  239266    2017-06-09 13:06:07-04:00      vndpnnpndfntt
  239267    2017-06-09 12:48:54-04:00      TbnFrbnTrbdfr
  239268    2017-06-09 12:16:59-04:00       Hrffn n Hpld
  239269    2017-06-09 12:06:12-04:00             Xbllfr
  239270    2017-06-09 11:27:33-04:00  TbttppfdTrbdfrFrz
  239271    2017-06-09 11:21:46-04:00         ND`jn`BjhD
  239272    2017-06-09 11:19:34-04:00      TbnFrbnTrbdfr
  239273    2017-06-09 10:55:01-04:00      bbndpntfbdfll
  239274    2017-06-09 10:55:01-04:00   JTTLJTTLFBVTNJDF
  ................(continued for years).................
  </code></pre>
  
  <p>For instance, using the above data, we see that user "<em>JTTLJTTLFBVTNJDF</em>" has posted at least three times in the last twenty four hours; that person only contributes <code>1</code> to the "number of unique authors in the last twenty four hours". </p>
  
  <p>The desired output would look like the following (depending on the prior 24 hours of data):</p>
  
  <pre><code>&gt;&gt;&gt; print some_function(df, past='24 hours', every='30 mins')
   Index                        Number_of_unique_authors_in_the_last_24_hours
   2017-06-09 15:00:00-04:00                                               12
   2017-06-09 14:30:00-04:00                                               11
   2017-06-09 14:00:00-04:00                                               13
   ...(and so forth)......
  </code></pre>
  
  <p>For clarity, this is saying at 15:00, there were 12 <em>different</em> people who had posted messages in the last twenty-four hours, based on the data.</p>
  
  <p>I have tried different combinations of <code>pd.Timestamp.ceil</code>, <code>groupby</code>, and <code>rolling</code>, but nothing close to what I want. An experienced person might know the right combination of things to do.</p>
  
  <p>Also, let me know if someone has a better title idea.</p>
  
  <hr>
  
  <p>edit: I'm a bit surprised something like below doesn't work.</p>
  
  <pre><code> series = df.set_index('Message Timestamp')['Message Author']
   series.resample('30 min').rolling('1D').nunique() #not supported
  </code></pre>
  
  <p>I know how to get a for-loop to do what I want, but it would be nice to find a pandas-powered way of doing things.</p>