jrdioko jrdioko - 7 months ago 111
Python Question

Calculating arithmetic mean (average) in Python

Is there a built-in or standard library method in Python to calculate the arithmetic mean (average) of a list of numbers?

NPE NPE
Answer

I am not aware of anything in the standard library. However, you could use something like:

float(sum(l))/len(l) if len(l) > 0 else float('nan')

In numpy, there's numpy.mean().