How do I calculate the mean of a column

后端 未结 5 1093
花落未央
花落未央 2020-12-25 10:42

Anyone know how can I calculate the mean of one these columns (on linux)??

sda               2.91    20.44    6.13    2.95   217.53   186.67    44.55     0.         


        
5条回答
  •  囚心锁ツ
    2020-12-25 11:28

    David Zaslavsky for the fun of it:

    with open("mean.txt", 'r') as f: 
        n,t = map(sum, zip(*((1, float(line.split()[1])) for line in f)))
    print t/n
    

提交回复
热议问题