I have a table of data and I want to create an average value the variable (f), for it to start at when the counter is at 1 and end before it becomes one again
This is what the start of the dataframe looks like
f counter
49.798 1
49.797 2
49.793 3
49.792 4
49.794 5
50.203 1
50.201 1
50.201 2
50.202 1
50.205 2
50.206 3
50.209 4
50.21 5
50.212 6
50.21 7
50.211 8
50.211 9
50.211 10
50.212 11
50.21 12
50.206 13
50.205 14
50.206 15
50.201 16
The output should be like this:
Average
49.7948
50.203
50.201
50.2079375
I have no idea how to go about doing this
I have tried this to just sum the values but it doesnt work
def sum_f(x):
global total
if counter == 1:
total == f
return int(total)
if counter == 1:
total == f
return int(total)
else:
total =+ f
return int(total)