I'd like to calculate the mean of an array in Python in this form:
Matrice = [1, 2, None]
I'd just like to have my None
value ignored by the numpy.mean
calculation but I can't figure out how to do it.
meannumpypython
I'd like to calculate the mean of an array in Python in this form:
Matrice = [1, 2, None]
I'd just like to have my None
value ignored by the numpy.mean
calculation but I can't figure out how to do it.
Best Solution
You are looking for masked arrays. Here's an example.
From the numpy docs linked above, "The numpy.ma module provides a nearly work-alike replacement for numpy that supports data arrays with masks."