0

I have the below dataframe test and my objective is to check if the time period repeats and if it repeats I want to group by and take a mean of repeated time rows

my input data

My desired output will be like

enter image description here

I have tried the below code

for i in range(len(test)-1):
    if test['time'][i] == test['time'][i+1]:

        test[i:i+1].groupby('time').mean().reset_index()
    else:

        break

But its not working as desired. Will appreciate any help. Thank you

Ahamed Moosa
  • 1,395
  • 7
  • 16
  • 30

0 Answers0