0

I have this NumPy array:

X = numpy.linspace(1, 10, 10)

I believe the output will become (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

Why is the shape of this array (10,)? I don't understand why it isn't (1,10).

mkrieger1
  • 10,793
  • 4
  • 39
  • 47
  • Why did you expect (1,10)? `np.array([1,2,3])` produces a (3,), not (1,3). Same with `arange`. Why should `linspace` be any different? Is there something in the docs? – hpaulj Mar 18 '21 at 15:37

1 Answers1

0

This is because you created a vector, and vectors are always in a single dimension. If you want to have shape, (1,10) you can specifiy the shape using X.reshape((1,10))

Lio
  • 152
  • 8