The following DataFrame (df) has 3 columns : Event
, Counts
and Length
where the Counts
column contains series of numbers. I would like to estimate the mean of each Counts
row and display it on a fourth one.
df =
Event Counts Length
0 [111240.0, 110530.0, 108540.0, 108540.0, 10838... 5
7 [117240.0, 119160.0, 120160.0, 121950.0, 12195... 6
13 [180420.0, 180420.0, 183840.0, 183840.0, 18384... 6
16 [160260.0, 159430.0, 159430.0, 157720.0, 15955... 14
I have tested the following expression without success.
df['mean'] = df['counts'].mean(axis = 1)
and other variations based on this line.
If I understand correctly, the problem due to the fact that the Count
column contains more than one element.
I appreciate your help for this apparently easy problem.