Use rowNumber or denseRank to create a sequential row number for ordering your time series. Use lag or lead functions to compare the current row with the previous row. Filter rows where the current value is different from the previous one (i.e., removing consecutive duplicates).