0
import numpy as np  
from scipy import interpolate  
import pylab as py  
import pandas as pd  

def func(x1):  
    return x*np.exp(-5.0*x1**2)  
dataset=pd.read_excel('Messwerte_FIBRE1.xlsx')  
dataset=dataset.drop([0])  
index=[1]  
index2=[9]  
x=dataset.iloc[:, index]     
y=dataset.iloc[:, index2]  
x1=np.array(x)  
y1=np.array(y)  
fvals=func(x1)   

File "C:/Users/Windows 10/.spyder-py3/RBF.py", line 10, in func
return x*np.exp(-5.0*x1**2)

AttributeError: 'float' object has no attribute 'exp'
Any1 can help me to solve this problem? Here is the png of my textfile

4
  • 2
    would you mind providing how is your 'Messwerte_FIBRE1.xlsx'is? Commented May 11, 2018 at 16:54
  • You can see in above question again. In bottom I have attached a snapshot of my Excel file Commented May 11, 2018 at 18:25
  • would you mind explaining more what you want to achieve with this logic? At first, it seems that somehow you have assigned a float to np. Commented May 11, 2018 at 19:33
  • I have solved the problem by changing these two lines: x1=np.array(x,dtype=float) y1=np.array(y,dtype=float) Commented May 11, 2018 at 22:09

1 Answer 1

1

np.exp(...)

'float' object has no attribute 'exp'

This means that you likely have redefined the name np, and now it's a floating-point number and not the numpy module any more.

Look around your code for np = ....

Sign up to request clarification or add additional context in comments.

1 Comment

I think problem lies here: return x*np.exp(-5.0*x1**2)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.