Change your code to:

for element in my_series:
    if type(element) == float and pd.isna(element):
        print('do A')
    else:
        print('do B')

Edit following the comment by Peter

I on purpose didn't change the original concept of processing the source Series in a loop. It looks like both print instructions are rather "placeholders", to be replaced with one piece of code for NaN values and another for other values.

Answer from Valdi_Bo on Stack Overflow
🌐
Researchdatapod
researchdatapod.com › home › how to solve python attributeerror: ‘numpy.float64’ object has no attribute ‘isna’
How to Solve Python AttributeError: 'numpy.float64' object has no attribute 'isna' - The Research Scientist Pod
August 17, 2022 - This error occurs if you try to call isna() on a numpy.float64 object. If you want to evaluate whether a value is NaN or not in a Series or DataFrame object, you use can use the Series.isna() and DataFrame.isna() methods respectively.
Discussions

python - numpy.isnan(value) not the same as value == numpy.nan? - Stack Overflow
np.isnan(v) True I would have thought the two shoul... More on stackoverflow.com
🌐 stackoverflow.com
Numpy has not attribute?
Hi! I'm working on a bot to reply with suggestions for common python problems. This might not be very helpful to fix your underlying issue, but here's what I noticed about your submission: You are looping over an object using something like for x in range(len(items)): print(items[x]) This is simpler and less error prone written as for item in items: print(item) If you DO need the indexes of the items, use the enumerate function like for idx, item in enumerate(items): print(idx, item) If you think you need the indexes because you are doing this: for x in range(len(items)): print(items[x], prices[x]) Then you should be using zip: for item, price in zip(items, prices): print(item, price) More on reddit.com
🌐 r/learnpython
2
1
June 23, 2017
BUG: np.isna() is working
Describe the issue: I used to find na values from the data frame it used to work till 2 days before but from today as I tested it's not working. I tested in different IDEs that include Google C... More on github.com
🌐 github.com
September 20, 2023
python - Numpy isnan() fails on an array of floats (from pandas dataframe apply) - Stack Overflow
I have an array of floats (some normal numbers, some nans) that is coming out of an apply on a pandas dataframe. For some reason, numpy.isnan is failing on this array, however as shown below, each More on stackoverflow.com
🌐 stackoverflow.com
🌐
IQCode
iqcode.com › code › python › numpyfloat64-object-has-no-attribute-isnull
'numpy.float64' object has no attribute 'isnull' Code Example
September 29, 2021 - for element in my_series: if type(element) == float and pd.isna(element): print('do A') else: print('do B')
🌐
CSDN
devpress.csdn.net › python › 630460da7e6682346619ac5c.html
Error: 'float' object has no attribute 'isna' - DevPress官方社区
August 23, 2022 - 问题:如何重塑熊猫。系列 在我看来,它就像 pandas.Series 中的一个错误。 a = pd.Series([1,2,3,4]) b = a.reshape(2,2) b b 有类型 Series 但无法显示,最后一条语句给出异常,非常冗长,最后一行是“TypeError: %d format: a number is required, not numpy.ndarray”。 b.sha
🌐
Reddit
reddit.com › r/learnpython › numpy has not attribute?
r/learnpython on Reddit: Numpy has not attribute?
June 23, 2017 -

I am trying to plot a .txt file of lines of the form: filename.txt date magnitude V098550.txt 362.0 3.34717962317 but I am getting the error "numpy.float64' object has no attribute 'replace'". Does anyone know if this is a syntax error with numpy, or how I can resolve my issue?

import numpy as np
import matplotlib.pyplot as plt
x, y = np.loadtxt ("condensed.txt", usecols=(1, 2),        
delimiter=",", unpack=True)
for ii in range (len(x)): x[ii].replace('.txt', '.lc\n') jd, npmag = np.loadtxt ("/net/jovan/export/jovan/oelkerrj/Vela/rotation/Vela/"+x[ii], usecols= (1, 2), unpack=True)
    plt.scatter (jd, npmag)
    plt.xlabel ('Time')
    plt.ylabel ('Mag')
    plt.ylim ([max (npmag), min (npmag)])
    plt.show() # aftertest comment this out
    fileName = x[ii][:-3] + ".png"
    plt.savefig(fileName)

print "done"

Top answer
1 of 2
2
Hi! I'm working on a bot to reply with suggestions for common python problems. This might not be very helpful to fix your underlying issue, but here's what I noticed about your submission: You are looping over an object using something like for x in range(len(items)): print(items[x]) This is simpler and less error prone written as for item in items: print(item) If you DO need the indexes of the items, use the enumerate function like for idx, item in enumerate(items): print(idx, item) If you think you need the indexes because you are doing this: for x in range(len(items)): print(items[x], prices[x]) Then you should be using zip: for item, price in zip(items, prices): print(item, price)
2 of 2
1
Numpy arrays are not the same as strings, so they don't have the normal string methods. However, there are function versions of most of the string methods you can use: x = np.replace(x, '.txt', '.lc') This had the advantage of operating on every element of the array at once, rather than having to do each one-at-a-time in a loop. So the above line would go before the loop, not inside it. To convert x[ii] to a normal string you can use the x[ii].tolist(). Despite what the name implies, tolist doesn't convert to a list for numpy scalars (which x[ii]) is, instead it converts to the appropriate native python type (so numpy ints to python integers, numpy floats to python floats, numpy strings to python strings, etc.). You can then use normal python string operations on the result.
🌐
GitHub
github.com › numpy › numpy › issues › 24759
BUG: np.isna() is working · Issue #24759 · numpy/numpy · GitHub
September 20, 2023 - --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-5-4ce8187e45dc> in <cell line: 1>() ----> 1 np.isna(np.nan) /usr/local/lib/python3.10/dist-packages/numpy/__init__.py in __getattr__(attr) 309 return Tester 310 --> 311 raise AttributeError("module {!r} has no attribute " 312 "{!r}".format(__name__, attr)) 313 AttributeError: module 'numpy' has no attribute 'isna' Below is the output for the code import sys, numpy; print(numpy.version); print(sys.version) 1.23.5 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] ... Numpy does have isnan, for finding NaN floating point values, and isnat for finding NaT timestamp values.
Find elsewhere
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.6.dev0 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.5 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
Statology
statology.org › home › how to fix: typeerror: ‘numpy.float64’ object is not callable
How to Fix: TypeError: 'numpy.float64' object is not callable
August 25, 2021 - import numpy as np #define array of data data = np.array([3.3, 4.1, 4, 5.6, 8.1, 9.9, 9.7, 10.2]) #attempt to find minimum value of array min_val = min(data) #view minimum value print(min_val) TypeError: 'numpy.float64' object is not callable · We receive a TypeError because we used the min() function. ... import numpy as np #define array of data data = np.array([3.3, 4.1, 4, 5.6, 8.1, 9.9, 9.7, 10.2]) #attempt to find minimum value of array min_val = np.min(data) #view minimum value print(min_val) 3.3 ... How to Fix: columns overlap but no suffix specified How to Fix: ‘numpy.ndarray’ object has no attribute ‘append’ How to Fix: if using all scalar values, you must pass an index How to Fix: ValueError: cannot convert float NaN to integer
🌐
GitHub
github.com › numpy › numpy › issues › 6746
nan in float64 does not evaluate to nan · Issue #6746 · numpy/numpy · GitHub
November 29, 2015 - Hello It is very likely that this is a nooby misunderstanding from my part. But shouldn't np.float64(np.nan) is np.nan evaluate as True(on Python3)? These two do at least: np.isnan(np.float64(np.nan)) and np.float(np.nan) is np.nan Thank...
Author: numpy
🌐
GitHub
github.com › blaze › blaze › issues › 1286
isnan() woes · Issue #1286 · blaze/blaze · GitHub
November 9, 2015 - In [48]: x['a'].isnan() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-48-641efc28480c> in <module>() ----> 1 x['a'].isnan() /Users/ksmith/work/blaze/blaze-repo/blaze/expr/expressions.pyc in __getattr__(self, key) 169 pass 170 try: --> 171 result = object.__getattribute__(self, key) 172 except AttributeError: 173 fields = dict(zip(map(valid_identifier, self.fields), AttributeError: 'Field' object has no attribute 'isnan'
Author: blaze
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-fix-numpy-float64-object-cannot-be-interpreted-as-an-integer
How to Fix: ‘numpy.float64’ object cannot be interpreted as an integer - GeeksforGeeks
December 19, 2021 - ‘numpy.ndarray’ object has no attribute ‘index’ is an attribute error which indicates that there is no index method or attribute available to use in Numpy array.
Top answer
1 of 9
65

The answer is already provided in the comments by @mattdmo and @tdelaney:

  • NumPy 1.20 (release notes) deprecated numpy.float, numpy.int, and similar aliases, causing them to issue a deprecation warning

  • NumPy 1.24 (release notes) removed these aliases altogether, causing an error when they are used

In many cases you can simply replace the deprecated NumPy types by the equivalent Python built-in type, e.g., numpy.float becomes a "plain" Python float.

For detailed guidelines on how to deal with various deprecated types, have a closer look at the table and guideline in the release notes for 1.20:

...

To give a clear guideline for the vast majority of cases, for the types bool, object, str (and unicode) using the plain version is shorter and clear, and generally a good replacement. For float and complex you can use float64 and complex128 if you wish to be more explicit about the precision.

For np.int a direct replacement with np.int_ or int is also good and will not change behavior, but the precision will continue to depend on the computer and operating system. If you want to be more explicit and review the current use, you have the following alternatives:

  • np.int64 or np.int32 to specify the precision exactly. This ensures that results cannot depend on the computer or operating system.
  • np.int_ or int (the default), but be aware that it depends on the computer and operating system.
  • The C types: np.cint (int), np.int_ (long), np.longlong.
  • np.intp which is 32bit on 32bit machines 64bit on 64bit machines. This can be the best type to use for indexing.

...

If you have dependencies that use the deprecated types, a quick workaround would be to roll back your NumPy version to 1.24 or less (as suggested in some of the other answers), while waiting for the dependency to catch up. Alternatively, you could create a patch yourself and open a pull request, or monkey patch the dependency in your own code.

2 of 9
39

In the 1.24 version:

The deprecation for the aliases np.object, np.bool, np.float, np.complex, np.str, and np.int is expired (introduces NumPy 1.20). Some of these will now give a FutureWarning in addition to raising an error since they will be mapped to the NumPy scalars in the future.

pip install "numpy<1.24" to work around it.

In [1]: import numpy as np

In [2]: np.__version__
Out[2]: '1.23.5'

In [3]: np.float(3)
<ipython-input-3-8262e04d58e1>:1: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  np.float(3)
Out[3]: 3.0
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.1 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.3 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-attributeerror-module-numpy-has-no-attribute-float-in-python
How to fix AttributeError: module numpy has no attribute float' in Python - GeeksforGeeks
July 23, 2025 - This solution ensures compatibility with recent numpy versions and avoids the "AttributeError: module 'numpy' has no attribute 'float'" error. ... Explicitly specifying Python types involves using dtype='float64' or dtype='float32' in numpy arrays instead of relying on the deprecated np.float attribute.
🌐
YouTube
youtube.com › watch
Pandas : Error: 'float' object has no attribute 'isna'" - YouTube
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Published: February 12, 2022
🌐
Bobby Hadz
bobbyhadz.com › blog › python-attributeerror-float-object-has-no-attribute
AttributeError: 'float' object has no attribute 'X' (Python) | bobbyhadz
The Python AttributeError: 'float' object has no attribute occurs when we try to access an attribute that doesn't exist on a floating-point number.