mee mee mee mee - 1 year ago 1286
Python Question

why numpy.ndarray is object is not callable in my simple for python loop

hi i loaded txt file that got two column matrix (e.g. below)

[ 1 3
2 4
3 5
2 0]

My calculation is just to sum two column in each row i.e. 1+3, 2+4, 3+5 and 2+0. I use the below code:

data=np.loadtxt(fname="textfile.txt")## to load the above two column
xy= data
for XY in xy:
print (Z)

But it said numpy.ndarray is object is not callable. What is it happen and how can I do this simple calculation? Thanks.

Answer Source

The error TypeError: 'numpy.ndarray' object is not callable means that you tried to call a numpy array as a function.



Instead of

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download