[SciPy-User] numpy mean
Oleksandr Huziy
guziy.sasha at gmail.com
Thu Jul 28 01:06:05 EDT 2011
Hi,
you can do the following
>>> arr = np.array([array1,array2,array3])
>>> arr
array([[ 2, 4, 8],
[ 4, 8, 12],
[ 9, 3, 15]])
>>> np.mean(arr, axis = 1)
array([ 4.66666667, 8. , 9. ])
>>> np.mean(arr, axis = 0)
array([ 5. , 5. , 11.66666667])
cheers
--
Oleksandr
2011/7/28 questions anon <questions.anon at gmail.com>
> Hi All,
> I thought this would be a relatively easy thing to do but the more I look
> the more confused I become!
>
> I have a netcdf file containing hourly temperature data for given region
> for a month.
> I would like to find the mean/average of particular periods (i.e. 3 hours).
>
> e.g. this is what I would like:
>
> array1=[2,4,8]
> array2=[4,8,12]
> array3=[9,3,15]
>
> meanofarrays=np.mean(array1,array2,array3)
> print meanofarrays
> >>>[5,5,11]
>
> Is there a routine that will do what I am after?
> If not I seem to be able to sum the arrays together and then divide by
> another array, but I will need to produce an array to match the extent and
> all values will need to be equal to the number of arrays I have summed. Can
> anyone help with producing this array?
>
> i.e.
> sumofarray=[15,15,35]
> numberofarrays=[3,3,3]
> meanofarrays=np.divide[sumofarrays,numberofarrays]
> print meanofarrays
> >>>[5,5,11]
>
> Any feedback will be greatly appreciated!!!
>
>
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110728/331ab6ba/attachment.html>
More information about the SciPy-User
mailing list