[Numpy-discussion] numpy.mean problems

ferreirafm ferreirafm at lim12.fm.usp.br
Fri Dec 9 14:47:50 EST 2011


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'>
Traceback (most recent call last):
  File "/home/ferreirafm/bin/cross.py", line 213, in <module>
    main()
  File "/home/ferreirafm/bin/cross.py", line 204, in main
    stats(filename)
  File "/home/ferreirafm/bin/cross.py", line 146, in stats
    print np.mean(stat_array, axis=0)
  File "/usr/lib64/python2.7/site-packages/numpy/core/fromnumeric.py", line
2374, in mean
    return mean(axis, dtype, out)
TypeError: unsupported operand type(s) for +: 'numpy.void' and 'numpy.void'
-- 
View this message in context: http://old.nabble.com/numpy.mean-problems-tp32945124p32945124.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.




More information about the NumPy-Discussion mailing list