g.Still
g.Still

Reputation: 95

TypeError: 'numpy.ndarray' object is not callable within for loop Python

I am trying to call a method multiple times with the use of a for loop but change the value of a variable (i) that will be passed into the method (method1) on every iteration. I planned to do this within a for loop but keep getting the error:

TypeError: 'numpy.ndarray' object is not callable

I have looked at other similar issues but none seem to resolve my issue or provide a way to still call the method in the way I desire.

array = np.array([1, 63, 96, 122, 35, 52, 67, 0.01])

for i in array:
    result = method1(collection, data, i)
    method1= price.dot(result)

Any help with this would be much appriciated!

Upvotes: 2

Views: 946

Answers (2)

sanchitarora
sanchitarora

Reputation: 910

In your for loop when you assign method1 = price.dot(result) method1 is now a numpy.ndarray and on the next iteration of the loop it is not callable anymore

Upvotes: 1

Duc Tran
Duc Tran

Reputation: 1

You should be able to loop through numpy array with that. Just wondering you don't have a space between 'method' and '1' in your code, do you? Because there shouldn't be a space there...

Upvotes: 0

Related Questions