I understand the basics of numpy
(Pandas) broadcasting but got stuck on this simple example:
x = np.arange(5)
y = np.random.uniform(size = (2,5))
z = x*y
print(z.shape) #(2,5)
My understanding of the z shape is that you had a (1,5)
array multiplied with a (2,5)
array, the trailing dimension for 5 is equal so you end up with a 2x5
array. Okay that sounds good. My problem is why is x.shape = (5,)
? Isn't it one-dimensional so it's really 1x5
?