My data looks like this (ch
= channel, det
= detector):
ch det time counts
1 1 0 123
2 0 121
3 0 125
2 1 0 212
2 0 210
3 0 210
1 1 1 124
2 1 125
3 1 123
2 1 1 210
2 1 209
3 1 213
Note, in reality, the time column is a float
with 12 or so significant digits, still constant for all detectors of 1 measurement, but its value is not predictable, nor in a sequence.
What I need to create is a data frame that looks like this:
c time mean_counts_over_detectors
1 0 xxx
2 0 yyy
1 1 zzz
1 1 www
I.e., I would like to apply np.mean
over all counts of the detectors of 1 channel at each time separately. I could write kludgy loops, but I feel that pandas must have something built-in for this. I am still a beginner at pandas, and especially with MultiIndex there are so many concepts, I am not sure what I should be looking for in the docs.
The title contains 'condition' because I thought that maybe the fact that I want the mean over all detectors of one channel for the counts where the time is the same can be expressed as a slicing condition.