[Numpy-discussion] first post, simple questions

Pierre GM pgmdevlist@gmail....
Thu Aug 21 12:58:12 CDT 2008


On Thursday 21 August 2008 13:40:47 Prashant Saxena wrote:
> Hi,
>
> numpy rocks!!!
>
> import numpy
> linsp = numpy.linspace
> red = linsp(0, 255, 50)
> green = linsp(125, 150, 50)
> blue = linsp(175, 255, 50)
>
> array's elements are float. How do I convert them into integer?

Use  .astype(int)
red = linsp(0, 255, 50).astype(int)

> I need to build a new array from red, green, blue. like this:
>
> [[ red[0], green[0], blue[0] ],

numpy.column_stack((red,green,blue))




More information about the Numpy-discussion mailing list