python - How do you create a numpy vertical arange? -


>>> print np.array([np.arange(10)]).transpose()  [[0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]] 

is there way vertical arange without having go through these steps?

you can use np.newaxis:

>>> np.arange(10)[:, np.newaxis] array([[0],        [1],        [2],        [3],        [4],        [5],        [6],        [7],        [8],        [9]]) 

np.newaxis alias none, , added numpy developers readability. therefore np.arange(10)[:, none] produce same exact result above solution.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -