[Numpy-discussion] numpy.mean problems

Stéfan van der Walt stefan at sun.ac.za
Fri Dec 9 19:12:28 EST 2011


On Fri, Dec 9, 2011 at 11:47 AM, ferreirafm <ferreirafm at lim12.fm.usp.br> wrote:
>
> Hi everyone,
> I'm quite new to numpy and python either. Could someone, please, tell me
> what I'm doing wrong?
> Here goes my peace of code:
>
> def stats(filename):
>    """Utilility to perform some basic statistics on columns."""
>    tab = get_textab(filename)
>    stat_list = [ ]
>    for row in sort_tab(tab):
>        if row['length'] >= 15:
>            stat_list.append(row)
>    stat_array = np.array(stat_list)
>    print type(sort_tab(tab))
>    print type(stat_array)
>    #print stat_array.mean(axis=0)
>    print np.mean(stat_array, axis=0)
>
> Which results in:
> <type 'numpy.ndarray'>
> <type 'numpy.ndarray'>

When posting to the mailing list, it's a good idea to have a small,
self contained example (otherwise we can't reproduce your problem).
In this specific case, I'd like to be able to see what the outputs of
"print tab" and "print stat_array" are.

Regards
Stéfan



More information about the NumPy-Discussion mailing list