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

madhavanbomidi at gmail.com madhavanbomidi at gmail.com
Tue Jun 11 12:52:42 EDT 2019


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



More information about the Python-list mailing list