I need to do some analysis on a large dataset from a hydrolgeology field work. I am using NumPy. I want to know how I can:
-
multiply e.g. the 2nd column of my array by a number (e.g. 5.2). And then
-
calculate the cumulative sum of the numbers in that column.
As I mentioned I only want to work on a specific column and not the whole array.
with some mocked data:
just a few simple rules are required to grok element selection (indexing) in NumPy:
NumPy, like Python, is 0-based, so eg, the “1” below refers to the second column
commas separate the dimensions inside the brackets, so [rows, columns], eg, A[2,3] means the item (“cell”) at row three, column four
a colon means all of the elements along that dimension, eg, A[:,1] creates a view of A’s column 2; A[3,:] refers to the fourth row