# [Numpy-discussion] strange nan in np.ma.average

Chao YUE chaoyuejoy@gmail....
Tue Jan 3 03:01:39 CST 2012

```Dear all numpy users,

I have 10 90X720 arrays. let's say they are in a list 'a' with each element
then I create a new empty ndarray: data

data=np.empty([10,90,720])

##first I store all the 10 ndarray in a 10X90X720 array:
for i,d in enumerate(a):
data[i]=a

data.shape=(10, 90, 720)
then I use data_av=np.ma.average(data, axis=0) to get the average.

The strange thing is, I don't have any 'nan' in all the 10 90X720 array,
but I have nan value in the final data_av.
how does this come?

In [26]: np.nonzero(np.isnan(data_av))
Out[26]:
(array([ 0,  0,  2,  2,  3,  5,  5,  6,  6,  6,  6,  7,  8,  8,  8,  9, 10,
10, 10, 11, 11, 12, 13, 13, 14, 17, 17, 19, 22, 22, 44, 63, 64, 64,
67, 68, 71, 72, 73, 76, 77, 77, 78, 79, 80, 80, 81, 82, 82, 84, 85,
85, 86, 86, 87, 87, 88, 89, 89, 89]),
array([159, 541, 497, 548,  90,  97, 170, 244, 267, 587, 590, 150, 126,
168, 477, 240, 271, 277, 588,  99, 179, 528,  52, 256, 230, 109,
190, 617, 377, 389, 707, 539, 193, 361, 262, 465, 100, 232, 206,
90,  87,  93, 522, 229, 200, 482, 325, 195, 239, 228, 159, 194,

thanks,

Chao

--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120103/c5e44e0b/attachment.html
```