TypeError: unsupported operand type(s) for ^: ‘float‘ and ‘int‘

    aera['down_aera'] = df_10minv1.iloc[:, : 6].apply(lambda x: sum(\
        [0.5*(abs(i[0][0])/(abs(i[0][0])+abs(i[0][1])))*i[1]*i[0][0]*(1-(i[0][1]/i[0][0])^2) if i[0][0]*i[0][1] < 0 \
             else 0.5*(i[0][0]+i[0][1])*i[1] for i in zip(zip(x[:-1], x[1:]), height[:5])]), axis=1)
  File "", line 2, in <lambda>
    [0.5*(abs(i[0][0])/(abs(i[0][0])+abs(i[0][1])))*i[1]*i[0][0]*(1-(i[0][1]/i[0][0])^2) if i[0][0]*i[0][1] < 0 \
  File "", line 2, in <listcomp>
    [0.5*(abs(i[0][0])/(abs(i[0][0])+abs(i[0][1])))*i[1]*i[0][0]*(1-(i[0][1]/i[0][0])^2) if i[0][0]*i[0][1] < 0 \
TypeError: unsupported operand type(s) for ^: 'float' and 'int'

修改:
把 a^2 表示a的2次方,改为 a**2,也是表示a的2次方
参考:https://blog.csdn.net/chundongg/article/details/98889600

你可能感兴趣的:(#,pandas,python)