Editing.
Suppose I have the following series in pandas:
>>>p
0 0.0
1 0.0
2 0.0
3 0.3
4 0.3
5 0.3
6 0.3
7 0.3
8 1.0
9 1.0
10 1.0
11 0.2
12 0.2
13 0.3
14 0.3
15 0.3
I need to identify each sequence of consecutive duplicates - its first and last index. Using the above example, I need to identify the first sequence of 0.3 (from index 3 to 7) independently from the last sequence of 0.3 (from index 13 to 15).
Using Series.duplicated is insufficient because:
*using keep='first' marks all first instances of duplicates False, but will leave index 13 as True because it is not the first appearance of 0.3.
*Same goes for keep='last'
*keep=False just marks all of the entries as True.
Thank you!