python multiply one column of array by a value

Solutions on MaxInterview for python multiply one column of array by a value by the best coders in the world

showing results for - "python multiply one column of array by a value"
Monica
26 May 2018
1import numpy as np
2# Let a be some 2d array; here we just use dummy data 
3# to illustrate the method
4a = np.ones((10,5))
5# Multiply just the 2nd column by 5.2 in-place
6a[:,1] *= 5.2
7
8# Now get the cumulative sum of just that column
9csum = np.cumsum(a[:,1])
10