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.

Skip to content
# Python – How to use numpy with ‘None’ value in Python

###### Related Question

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.

- Python – How to execute a program or call a system command
- Python – How to parse a string to a float or int
- Python – How to print without a newline or space
- Python – Convert bytes to a string
- Python – How to sort a dictionary by value
- Python – How to reverse a list
- Python – Renaming column names in Pandas
- Python – Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3

## 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."