0

I need your help slicing a dataframe with a lot of repetitive sequences. For instance:

a = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3...]

I tried the drop_duplicates(subset= "", keep="last") options but I got something like a = [1, 2, 3] so only one sequence of numbers is left. For each sequence from 1 to 3, I need to get the last number.

I need the final result to be like: a = [1, 2, 3, 1, 2, 3...]

Thanks in advance

Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32

0 Answers0