I have this data frame called sum_2
.
I want to be able to take the mean of (total_tom
+ total_Tomato_CalR
+ total_CalR
) while ignoring NaN values and grouping by Time
, Type_of_mouse
, and Mouse_number
all at the same time since I don't want different Time
s, Type_of_mouse
, and Mouse_number
values adding with each other.
The output that I ideally want is (126.0 + 91.0 + 53.0)/3 = 90 (90 being the mean from adding the values altogether).
I believe that pandas
will automatically ignore NaN values when using .sum()
and .mean()
(correct me on this if I am wrong).
In [1]: sum__2
Out[1]:
Time Type_of_mouse Mouse_number total_tom total_Tomato_CalR total_CalR
15w pTam FF 6045 126.0
15w pTam FF 6551 91.0
15w pTam FF 9729 53.0
15w pTam WT 6046 109.0
15w pTam WT 6156 106.0
15w pTam WT 6835 129.0
15w pTam WT 9631 108.0
15w pTam WT A859 238.0
2w pTam FF 6606 70.0
2w pTam FF 6609 78.0
2w pTam FF 6649 178.0
2w pTam FF 9205 87.0
2w pTam FF 9211 133.0
2w pTam WT 6050 118.0
2w pTam WT A1257 138.0
8m pTam FF 8998 165.0
8m pTam FF 9004 106.0
8m pTam FF 9007 91.0
8m pTam FF 9048 100.0
8m pTam WT 9005 184.0
8m pTam WT 9043 173.0
8m pTam WT 9045 163.0
8m pTam WT 9224 187.0