Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why "None" has the same effect as "np.newaxis"? [duplicate]

Why None has the save effect of np.newaxis? For example, using:

np.arange(10)[:,None]

or:

np.arange(10)[:,np.newaxis]

both create:

array([[0],
       [1],
       [2],
       [3],
       [4],
       [5],
       [6],
       [7],
       [8],
       [9]])

Does anyone know the reason for np.newaxis==None?

like image 570
Saullo G. P. Castro Avatar asked Aug 10 '13 16:08

Saullo G. P. Castro


1 Answers

Thats because numpy.newaxis is an alias for None as it says in the documentation: None can also be used instead of newaxis.

like image 135
jabaldonedo Avatar answered Sep 25 '22 03:09

jabaldonedo