Expanding a vector by replicating elements individually

Peter Otten __peter__ at web.de
Wed Sep 22 08:30:42 CEST 2010


gburdell1 at gmail.com wrote:

> Given
> 
> m=numpy.array([[1, 2, 3]])
> 
> I want to obtain
> 
> array([[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]])

>>> numpy.array([1,2,3]).repeat(4)
array([1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3])

Peter




More information about the Python-list mailing list