How to use numpy with 'None' value in Python?

后端 未结 7 2375
甜味超标
甜味超标 2020-12-18 18:14

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 valu

7条回答
  •  误落风尘
    2020-12-18 18:31

    You can also use filter, pass None to it, it will filter non True objects, also 0, :D So, use it when you dont need 0 too.

    >>> filter(None,[1, 2, None])
    [1, 2]
    

提交回复
热议问题