AttributeError:Float' object has no attribute log /TypeError: ufunc 'log' not supported for the input types

508 views Asked by At

I have a series of fluorescence intensity data in a column ('2.4M'). I tried to create a new column 'ln_2.4M' by taking the ln of column '2.4M' I got an error:

AttributeError: 'float' object has no attribute 'log'

df["ln_2.4M"] = np.log(df["2.4M"])

I tried using a for loop to iterate the log over each fluorescence data in the column "2.4M":

ln2_4M = []
for x in df["2.4M"]:
    ln2_4M = np.log(x)
    print(ln2_4M)

Although it printed out ln2_4M as log of column "2.4M" correctly, I am unable to use the data because it gave alongside a TypeError: ufunc 'log' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'

Not sure why? - Any help at understanding what is happening and how to fix this problem is appreciated. Thanks

1

There are 1 answers

0
user15710294 On

.
I then tried using the method below and it worked:

df["2.4M"] = pd.to_numeric(df["2.4M"],errors = 'coerce')

df["ln_24M"] = np.log(df["2.4M"])