Improve code quality

is there a way I can write this code faster like looping through it is too slow when I have like 500k rows and I feel like the code is too complicated for vectorization or using apply ```

  row_index = 0
  while row_index<len(Animals.index)-2:
     current_animal = Animals.iat[row_index,20]

     while current_animal == Animals.iat[row_index,20]:
        row_index+=1

also animals is a dataframe

Posted Nov 6, 2022, 7:32 PM UTC · edited

510
Loading comments…