Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python multiply one column of array by a value

import numpy as np
# Let a be some 2d array; here we just use dummy data 
# to illustrate the method
a = np.ones((10,5))
# Multiply just the 2nd column by 5.2 in-place
a[:,1] *= 5.2

# Now get the cumulative sum of just that column
csum = np.cumsum(a[:,1])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #multiply #column #array
ADD COMMENT
Topic
Name
6+2 =