How to use numpy with ‘None’ value in Python?

You are looking for masked arrays. Here’s an example.

import numpy.ma as ma
a = ma.array([1, 2, None], mask = [0, 0, 1])
print "average =", ma.average(a)

From the numpy docs linked above, “The numpy.ma module provides a nearly work-alike replacement for numpy that supports data arrays with masks.”

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)