So to visualise the problem heres the mocked data that i use.
1s => 2840,
2s => 2042,
3s => 1106,
4s => 269,
5s => 409,
6s => 0,
7s => 449,
8s => 531,
9s => 910
What i would like to achieve is to get the time value (s) which applies to the all counts average, thats been weighted depending on the time and count.
As for simpler example to understand what i mean
1s => 10,
2s => 0,
3s => 10
The output would be 2s
It looks like the data that you're giving is something like: you ran many trials of the same experiment, which tests how long something takes— in 2840 trials it took 1 second, in 2042 trials it took 2 seconds, and so on...
In this case, one simply takes the weighted average: $$\frac{2840+4084+3318+1076+2045+0+3143+4248+8190}{2840+2042+1106+269+409+0+449+531+910} = 3.38288920056\dots. $$