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

Dharhas Pothina Dharhas.Pothina@twdb.state.tx...
Fri Jun 6 12:16:10 CDT 2008


Thanks to all of you. I used the c_[] technique.

- dharhas

>>> Michael Hearne <mhearne@usgs.gov> 6/6/2008 11:44 AM >>>
Here's a simple example that I think demonstrates what you want to do:
a = zeros((4,5))
b = ones((4,1))
c = hstack((a,b))

--Mike

Dharhas Pothina wrote:
> 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
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org 
> http://projects.scipy.org/mailman/listinfo/scipy-user 
>   

-- 
------------------------------------------------------
Michael Hearne
mhearne@usgs.gov 
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.
------------------------------------------------------

_______________________________________________
SciPy-user mailing list
SciPy-user@scipy.org 
http://projects.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-user mailing list