[SciPy-user] Adding new columns to 2D array & populating them from another array.

Dharhas Pothina Dharhas.Pothina@twdb.state.tx...
Fri Jun 6 11:32:01 CDT 2008


Hi,

I have an array 'a'

a = 
array([[2006,    1,    3,    9,   40],
       [2006,    1,    3,   10,    9],
       [2006,    1,    3,   10,   40],
       ..., 
       [2008,    3,   20,   10,   27],
       [2008,    3,   20,   10,   51],
       [2008,    3,   20,   12,    2]])

where a.shape = (420, 5)

I have other arrays b,c etc of the shape (420,) (say b contains all 99's and c contains all 50's)

how to I add the new arrays to 'a' to form an array 

  array([[2006,    1,    3,    9,   40 , 99, 50],
       [2006,    1,    3,   10,    9, 99 , 50],
       [2006,    1,    3,   10,   40, 99, 50],
       ...,
       [2008,    3,   20,   10,   27, 99, 50 ],
       [2008,    3,   20,   10,   51, 99, 50],
       [2008,    3,   20,   12,    2, 99, 50]])

I've tried hstack but I'm not sure how to use it with 2D arrays.

thanks

- dharhas


More information about the SciPy-user mailing list