'float' object has no attribute 'sqrt'

1.4k Views Asked by At

I am trying to obtain the gumbel_r of this input list using gumbel_r.fit() and gumbel_r.ppf()

contoh1 = pd.read_excel('data.xlsx',header=None,sheet_name='Sheet7'
dn=contoh1.columns
y1 =contoh1[dn[1]][37:43]
y2 =contoh1[dn[2]][21:43]
y3 =contoh1[dn[3]][21:43]
y4 =contoh1[dn[4]][1:43]
y5 =contoh1[dn[5]][22:44]
gmb=[y1,y2,y3,y4,y5]

To obtain that output I used the code (it goes through a loop)

ch_res={}
parameter_9={}
Rx_9={}
Fx_9 = 0.5

for i in range (len(gmb)):
     ch_res[i] = np.array(gmb,dtype=object)
     parameter_9[i]= gumbel_r.fit(ch_res[i])
     Rx_9[i]= gumbel_r.ppf(Fx_9,*parameter_9[i])

but i got the attribute error when i run parameter_9[i] it says 'float' object has no attribute 'sqrt'. please help me what should i do about the code

1

There are 1 best solutions below

0
Warren Weckesser On

Not all functions in SciPy are designed to handle object arrays. Instead of creating object arrays to pass to gumbel_r.fit(), create arrays of numpy.float64. Change this line:

     ch_res[i] = np.array(gmb,dtype=object)

to

     ch_res[i] = np.array(gmb, dtype=np.float64)

Actually, I think that should be

     ch_res[i] = np.array(gmb[i], dtype=np.float64)