How does numpy.newaxis work and when to use it?


I'm trying


 and the result gives me a 2-d plot frame with x-axis from 0 to 1. 

However, when I try using numpy.newaxis to slice a vector,

[ 0.04965172 0.04979645 0.04994022 0.05008303]
vector[:, np.newaxis][0:4,]
[[ 0.04965172]
[ 0.04979645]
[ 0.04994022]
[ 0.05008303]]

Is it the same thing except that it changes a row vector to a column vector?

Generally, what is the use of,waxis and in which circumstances should we use it?



There are no replies to this topic.

If you want to unleash your potential in this competitive field, please visit the Python course page for more information, where you can find the Python tutorials and Python frequently asked interview questions and answers as well.


This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
Protected by Astra Security