This is an example of a larger dataframe.
df = pd.DataFrame({"DateTime":["2020-04-02 06:06:22","2020-04-02 06:12:22","2020-04-02 06:35:34","2020-04-02 07:06:09",
"2020-04-02 07:10:34","2020-04-02 07:41:44"],
"Data":[23, 31, 10, 23, 56, 81]})
# column DateTime type must be datetime64[ns]
df["DateTime"] = df["DateTime"].astype("datetime64[ns]")
df
Out[8]:
DateTime Data
0 2020-04-02 06:06:22 23
1 2020-04-02 06:12:22 31
2 2020-04-02 06:35:34 10
3 2020-04-02 07:06:09 23
4 2020-04-02 07:10:34 56
5 2020-04-02 07:41:44 81
I would like to drop a row if the date in df["DateTime"] in the row below occurs faster than 15 minutes when compared to the actual row. And the result should be like this:
DateTime Data
0 2020-04-02 06:06:22 23
2 2020-04-02 06:35:34 10
3 2020-04-02 07:06:09 23
5 2020-04-02 07:41:44 81
Does anyone know any condition I could use to set these intervals (every 15 min) and drop these rows?
Thanks