Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python sum over specific indexes

# You can use sum directly after indexing with indices:
a = np.array([1,2,3,4])
indices = [0, 2] 
a[indices].sum()
# Result: 4
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #sum #specific #indexes
ADD COMMENT
Topic
Name
5+9 =