TypeError: 'numpy.float64' object is not callable


def pingyu(df):
    "F1"
    f1 = sum([x for x in df])/len(df)
    "F2"
    f2  = math.pow(sum([(x-f1)**2 for x in df]),2) / (len(df)-1)
    "f3"
    f3 = sum([pow((x-f1),3) for x in df])/(pow(math.sqrt(f2),3)*len(df))
    "f4"
    f4 = sum([pow((x-f1),4) for x in df]) /pow(f2,2)*len(df)
    p_y = [round(f1,3),round(f2,3),round(f3,3),round(f4,3)]
    return p_y
if __name__ == '__main__':
    a=records1
    b = pingyu(a)
b

写了一段程序,刚写完的时候跑了一下,能跑通,过了几天再跑的时候报错:TypeError: ‘numpy.float64’ object is not callable,很郁闷,找了半天也没找到哪儿哪儿错了,然后单独拿出一句话进行调试:
f1 = sum([i for i in records1])/len(records1)
发现还是报错。
但是 [i for i in records1] 没有报错,那问题就出在 sum() ,我找了资料查了一下,改为 np.sum() 就可以跑通了。
f1 = np.sum([i for i in records1])/len(records1)

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值