What I want to do is take a numpy array like this:
[[1, 2, 4, 7, 9, 15, 0],
[3, 4, 3, 5, 10, 2, -2],
[5, 6, 56, 7, 20, 1, 2]]
I want to take each rows last column and divide that by the previous row’s 4th column and take the result and add it to the array as a new dimension the output I want should look like this
[[1, 2, 4, 7, 9, 15, 0, 0],
[3, 4, 3, 5, 10, 2, -2, -.2857],
[5, 6, 56, 7, 20, 1, 2, .4]]
Can this be done without a for loop? (Ok I guess it’s not efficient to do this without a for loop) But I’m still not sure how to do it with one either
1 Answer