I have a NumPy array x = np.array([[1, 2, 3], [4, 6, 8]]), and I want to divide every element by y. However, y is not a single number, but an array, y = np.array([2, 4]). I want to divide each row of x by each row of y, to return np.array([[0.5, 1.0, 1.5], [1.0, 1.5, 2.0]).
How can I do this? If I just run x / y, I get an error: ValueError: operands could not be broadcast together with shapes (2,3) (2,)
x/y[:,None]?