This is probably a really simple question, but I am not figuring this out.
I have a 2D numpy array, which is of shape (3,2) and a 1D array of shape (3,):
A = [[2,4],[6,8][10,12]]
B = [1,2,4]
I would like to divide array A by array B, resulting in:
[[2,4],[3,4][2.5,3]]
But numpy will not let me do this, I think because the shape is not right. I get the familiar 'operands could not be broadcast together with shapes (10,2) (10,)' error.
I tried things with reshape and swapaxis, but it is not working. I would much prefer to be able to do this without a for loop (because I need to do this many many times with large arrays) and without having to swap the axis of array A (because other arrays are if this shape).
Can you guys help me?