drop_consecutive_duplicates
- qf_lib.common.utils.miscellaneous.consecutive_duplicates.drop_consecutive_duplicates(series: QFSeries, method) QFSeries [source]
Removes consecutive duplicates (e.g. 3 consecutive 1 values should be merged into one with a date of the first/last occurrence in the series).
- Parameters:
series (QFSeries) – series from which the consecutive duplicates should be removed
method – Method.KEEP_FIRST: keep the first occurrence Method.KEEP_LAST: keep the last occurrence
- Returns:
the series of the first occurrences of the values in each of consecutive series of same values. For example: original series: - 2010-01-01 True - 2010-01-02 False - 2010-01-03 False - 2010-01-04 False - 2010-01-05 True - 2010-01-06 True - 2010-01-07 False - 2010-01-08 False after removing duplicates: - 2010-01-01 True - 2010-01-02 False - 2010-01-05 True - 2010-01-07 False
- Return type: