Open In App

How to Fix: TypeError: ‘numpy.float’ object is not callable?

Last Updated : 28 Nov, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see how to fix TypeError: ‘numpy.float’ object is not callable in Python. There is only one case in which we can see this error: 

If we try to call a NumPy array as a function, we are most likely to get such an error. 

Example:

Python3




import numpy as np
  
a = np.array([1,2,3])
  
a()


Output:

TypeError: 'numpy.ndarray' object is not callable

In the older version of Numpy, we used to see “numpy.float64” instead of “numpy.ndarray”.

Solution: 

This can be solved simply by removing the parenthesis after the array. 

Python3




import numpy as np
  
a = np.array([1,2,3])
  
a


Output:

array([1, 2, 3])

Here version of NumPy is ‘1.21.2’.

Note: In the earlier version of Numpy, we also used to get this error while using Python min() or max() function with a NumPy array. In the recent versions of NumPy, this is solved.  In the earlier versions, this particular error was supposed to be solved using np.max() or np.min() instead of min() and max(). 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads