osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why I am getting IndexError: tuple index out of range when converting a float value to a string?


I wrote the following lines of code:

xm = np.nanmean(x[indx],axis=None,dtype=float)   
xsd = np.nanstd(x[indx],axis=None,dtype=float)    

type(xm)    # np.float64
type(xsd    # np.float64

print(xm)      # 0.5414720812182742
print(xsd)     # 0.15748041033663002

print(str("{6.5f}".format(xm)))

I get the following error:

IndexError: tuple index out of range

Can someone suggest me why I am getting this error and how to overcome this?

Thanks in advance