2

I have read a code is like this x = np.linspace(0, 100, 10)[:, None]

I know the meaning of np.linspace(0,100,10)

But I don't know what does '[:,None]' mean

Echan
  • 1,395
  • 14
  • 15

1 Answers1

1

The [:, None] adds an extra axis making a two-dimensional the array of shape (10, 1). A more explicit version would be:

x = np.linspace(0, 100, 10)[:, np.newaxis]
xnx
  • 24,509
  • 11
  • 70
  • 109