以下是我试图用来获取结果的代码,但出现错误:
import numpy
array = [-1000,0,0,1094.60,0,0,1094.60]
for b in array:
a = round(numpy.irr(array), b-1) * 100
print (round(a,2))
错误:
TypeError: 'float' object cannot be interpreted as an integer
但是,只需替换那个“b-1”就可以让我的代码工作,但我不能使用它,因为数组可以尽可能大或尽可能小。我不允许手动输入替换“b-1”的数字。以下是相同的工作代码。
import numpy
array = [-1000,0,0,1094.60,0,0,1094.60]
for b in array:
a = round(numpy.irr(array), 6) * 100
print (round(a,2))
我需要一种方法来自动处理任何大小的数组。