how to calculate number of datapoints within a given time interval? I have a dataframe with one column which is a timestamp. I have converted that column to a datetime object using pandas to_datetime() method. However what I want is to count, for each time stamp, the number of timestamps that fall between this timestamp and prior 15 minutes. 


  For example: If a timestamp is (2018,7,6,13,55) [year,month, day,
  hour, minute format], then I want to count the number of timestamps
  (or datapoints) that fall between this timestamp and the timestamp
  (2018,7,6,13,40).


It is easy to see what needs to be done, but it involves repeatedly going back and forth over the dataset. I have close to 750,000 datapoints and what I am thinking is not efficient.

How can I do it efficiently? 

Any suggestion/hint would be highly appreciated.

Thanks.
The answer given by @Aditya is very good and educational despite the fact that the how is deprecated. So the right answer would be as follows:
df.resample(&quot;15T&quot;).agg({'count':'sum'})