jrdioko - 1 year ago 190

Python Question

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

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()`

.