From: Chris B. <chr...@ho...> - 2001-09-17 23:40:48
|
Mike Romberg wrote: > > I am attempting to create 2D arrays which are offset copies of a > given starting array. For example if I have a 2D array like this: > have any ideas? This is not quite as clean as i would like, but this will work: >>> a = array([[1, 2, 3], ... [4, 5, 6], ... [7, 8, 9]]) >>> m,n = a.shape >>> b[:m-1,:n-1] = a[1:,1:] >>> b array([[5, 6, 0], [8, 9, 0], [0, 0, 0]]) >>> if b does not have to be the same shape as a, then it is really easy: >>> b = a[1:,1:] -Chris -- Christopher Barker, Ph.D. Chr...@ho... --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ |