I would like to calculate in Python 2.7 the mean in specific rows (see also Question in R) and have a list at the end. Here in my case I want to take the mean duration for each event. So something like this (preferably in one line and computational fast):
mean_duration = [np.mean(r.duration, r[-1].duration) for r in catalog
if r.eventid == r[-1].eventid]
Unfortunately, I cannot do it like this because my class (and therefor my catalog) said that it cannot use getitem.
Here is the part of my data set:
Eventid Station Duration
20120525_0010H stat1 2.40
20120525_0010H stat2 2.80
20120525_0010H stat3 2.40
20120525_0223E stat1 2.80
20120525_0223E stat3 2.00
20120525_0225L stat2 3.20
20120525_0230B stat1 3.20
20120526_0019C stat3 3.20