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
python - AttributeError: 'numpy.float64' object has no attribute 'log10' - Stack Overflow
I am attempting to find the log slope of a ton of short series using sklearn.LinearRegression. The data is being pulled from rows of a pandas dataframe and looks like: bp01 1.12 bp02 1.12 bp... More on stackoverflow.com
🌐 stackoverflow.com
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
1
September 20, 2023
nan in float64 does not evaluate to nan
There was an error while loading. Please reload this page · 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 Thanks, Niko More on github.com
🌐 github.com
2
November 29, 2015
🌐
CopyProgramming
copyprogramming.com › howto › python-numpy-float64-object-has-no-attribute-isnan
Python: AttributeError: 'numpy.float64' object has no attribute 'isnan' in Python
April 6, 2023 - Differentiating between Numpy.isnan(value) and value == numpy.nan, AttributeError: 'float' object has no attribute 'isna', Error Occurs When Attempting to Fill NaN: 'fillna' Not an Attribute of 'numpy.float64', Error Occurs: 'mask' Attribute Not Found for 'numpy.float64' Object
🌐
GitHub
github.com › numpy › numpy › issues › 24759
BUG: np.isna() is working · Issue #24759 · numpy/numpy
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'
Author   kushal-h
🌐
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'>#
🌐
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')
Find elsewhere
🌐
GitHub
github.com › numpy › numpy › issues › 6746
nan in float64 does not evaluate to nan · Issue #6746 · numpy/numpy
November 29, 2015 - There was an error while loading. Please reload this page · 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 Thanks, Niko
Author   nheeren
🌐
Reddit
reddit.com › r/learnpython › [deleted by user]
AttributeError: 'numpy.float64' object has no attribute 'lower'
August 28, 2022 - Yup! that means you are running tokenizer on a column or data that is of the type float64 (64 bit float/number).
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.5.dev0 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
GitHub
github.com › scikit-learn › scikit-learn › issues › 3142
linear_model giving AttributeError: 'numpy.float64' object has no attribute 'exp' · Issue #3142 · scikit-learn/scikit-learn
May 10, 2014 - Per the stacktrace, I've tracked the problem to the lines in linear_model/base.py. I think that LinearClassifierMixin.decision_function is returning an array of dtype=object which makes np.exp() fail. None of the values in the array look to my eye like anything other than floats.
Published   May 10, 2014
Author   vm-wylbur
🌐
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 › pandas-dev › pandas › issues › 60106
BUG: isna() does not catch np.NaN when datatype is Float64 · Issue #60106 · pandas-dev/pandas
October 25, 2024 - import pandas as pd import numpy ... df['z']=df['y']/df['x'] df['z'].isna() The pandas isna() function does not catch NaN values that are of type np.NaN when using the Float64 datatype....
Author   mortnstak
🌐
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.
🌐
Saturn Cloud
saturncloud.io › blog › what-is-the-issue-with-numpy-isnan-on-float-arrays-from-pandas-dataframe-apply
What Is the Issue with Numpy isnan on Float Arrays from Pandas Dataframe Apply | Saturn Cloud Blog
August 25, 2023 - In the second example, the series ... To solve the issue, we need to ensure that the array obtained from the pandas dataframe apply() method has a compatible data type with the numpy.isnan() function....
🌐
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 - PyTorch and NumPy are different libraries with different data structures, so you need to convert between them properly. Here's how you c ... In this article we will discuss how to fix the value error - cannot convert float NaN to integer in Python. In Python, NaN stands for Not a Number.
🌐
Reddit
reddit.com › r/learnpython › 'numpy.float64' object has no attribute 'replace'
r/learnpython on Reddit: 'numpy.float64' object has no attribute 'replace'
March 8, 2021 -

Hallo Everyone,

I hope you are all fine, I have this code which I am getting error from , I run the same code on my Spyder and I do not get any error but when I run it on Jupyter Notebook I get this error :

'numpy.float64' object has no attribute 'replace'

this is the code that I have :

oli_row2 = df_oli.iloc[2].tolist()

idx = oli_row2.index("DB")

check_words = oli_row2[idx:]

exact_order = ['NN','ch','ab','An','tr','bcc',]

for i in range(len(check_words)):

if not(check_words[i].replace(" ","")==exact_order[i].replace(" ","")):

new_row = table.add_row()

new_row.cells[0].text = 'Oli'

new_row.cells[1].text = 'Words are out of order in Column'

new_row.cells[2].text = str(check_words[idx])

oli_flag = True

print('Out of order')

I googled lit bit but I could not find any solution.

Thank you in advance,
Best Regards,