[Numpy-discussion] New python/numpy user

paul.carrico at free.fr paul.carrico at free.fr
Mon Jul 3 15:55:52 EDT 2017


Dear All 

I'm a like matlab user (more specifically a Scilab one) for years, and
because I've to deal with huge ascii files (with dozens of millions of
lines), I decided to have a look to Python and Numpy, including
vectorization topics. 

Obviously I've been influenced by my current feedbacks. 

I've a basic question concerning the current code: why it is necessary
to transpose the column vector (still in the right format in my mind)?
does it make sens? 

Thanks 

Paul 

#################################### 
import numpy as np ## np = raccourci 

## works with a row vector
vect0 = np.random.rand(5); print vect0; print("\n")
mat = np.zeros((5,4),dtype=float)
mat[:,0]=np.transpose(vect0); print mat

## works while the vector is still in column i.e. in a right format,
isn't it?
vect0 = np.random.rand(5,1); print vect0; print("\n")
mat = np.zeros((5,4),dtype=float)
mat[:,0]=np.transpose(vect0); print mat

## does not work
vect0 = np.random.rand(5,1); print vect0; print("\n")
mat = np.zeros((5,4),dtype=float)
mat[:,0]=np(vect0); print mat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20170703/765adf3f/attachment.html>


More information about the NumPy-Discussion mailing list