[SciPy-user] Adding new columns to 2D array & populating them from another array.
Michael Hearne
mhearne at usgs.gov
Fri Jun 6 12:44:44 EDT 2008
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 at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
--
------------------------------------------------------
Michael Hearne
mhearne at usgs.gov
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.
------------------------------------------------------
More information about the SciPy-User
mailing list