Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python sum certain postions of array


a = np.array([1,2,3,4])   # numpy array with 4 positions
indices = [0, 2]          # list of the indices to sum.

a[indices].sum()		  # returns a[0] + a[2]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #sum #postions #array
ADD COMMENT
Topic
Name
5+6 =