Advertisement
furas

Python - numpy - mean

May 28th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. import numpy as np
  2.  
  3. data = np.array([ [40,60,3,3], [60,80,8,11], [80,100,30,41] ])
  4.  
  5.  
  6. for row in data:
  7.     d = row[0:2]
  8.     average = d.mean()
  9.     print(average)
  10.  
  11. # or
  12.  
  13. print(data[:,0:2].mean(axis=1))
  14.  
  15. '''
  16. 50.0
  17. 70.0
  18. 90.0
  19. [ 50.  70.  90.]
  20. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement