纯Python:
from __future__ import divisiondef mean(a): return sum(a) / len(a)a = [[240, 240, 239], [250, 249, 237], [242, 239, 237], [240, 234, 233]]print map(mean, zip(*a))
[243.0, 240.5, 236.5]
NumPy:
a = numpy.array([[240, 240, 239], [250, 249, 237], [242, 239, 237], [240, 234, 233]])print numpy.mean(a, axis=0)
Python 3:
from statistics import meana = [[240, 240, 239], [250, 249, 237], [242, 239, 237], [240, 234, 233]]print(*map(mean, zip(*a)))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)