我有一个列表,我想计算她的值的平均值(平均值?).当我这样做:
import numpy as np #in the beginning of the code goodPix = ['96.7958', '97.4333', '96.7938', '96.2792', '97.2292'] PixAvg = np.mean(goodPix)
我收到此错误代码:
ret = um.add.reduce(arr, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
TypeError: cannot perform reduce with flexible type
我试图找到一些帮助,但没有找到有用的东西
谢谢你们.
将列表从字符串转换为np.float:
>>> gp = np.array(goodPix, np.float) >>> np.mean(gp) 96.906260000000003