Playing with NumPy | Sololearn: Learn to code for FREE!

+1

Playing with NumPy

https://code.sololearn.com/cfEGBBQKlJb4/?ref=app What is a[None]? Why it is [[1 2 3 4 5]]? Code: import numpy as np a = np.array(range(6)) print(a) print(a[None]) Output: [1 2 3 4 5] [[1 2 3 4 5]]

12/10/2018 9:38:08 PM

portpass

2 Answers

New Answer

+2

https://stackoverflow.com/questions/1408311/numpy-array-slice-using-none

0

It's so simple! a[None] is a[None, :, :]! But it seemed really strange and unclear last night, when I was sleeppy ;)