This is my DataFrame:
dt value
2000-01-01 00:00:00 296.0
2000-01-01 00:05:00 296.0
2000-01-01 00:10:00 296.0
2000-01-01 00:15:00 296.25
2000-01-01 00:20:00 296.25
2000-01-01 00:25:00 296.25
2000-01-01 00:30:00 296.25
2000-01-01 00:35:00 296.25
2000-01-01 00:40:00 296.25
2000-01-01 00:45:00 296.5
2000-01-01 00:50:00 296.5
2000-01-01 00:55:00 296.5
2000-01-01 01:00:00 296.5
2000-01-01 01:05:00 296.5
2000-01-01 01:10:00 296.5
2000-01-01 01:15:00 296.75
2000-01-01 01:20:00 296.75
2000-01-01 01:50:00 297.0
2000-01-01 01:55:00 297.0
2000-01-01 02:00:00 297.0
2000-01-01 02:05:00 297.0
2000-01-01 02:10:00 297.0
2000-01-01 02:15:00 297.0
I want to remove adjacent duplicates.
The duplicate in the middle should remain. If the number of duplicates is even, take the next one from the middle. If there are 2 duplicates, take second.
Expected output:
dt value
2000-01-01 00:05:00 296.0
2000-01-01 00:30:00 296.25
2000-01-01 01:00:00 296.5
2000-01-01 01:20:00 296.75
2000-01-01 02:05:00 297.0
I read this post about duplicates, but it doesn't satisfy my conditions of choosing the middle element.
Pandas: Drop consecutive duplicates