Re: [Numpy-discussion] Simple way to shift array elements

2010-04-10 Thread Gökhan Sever
On Sat, Apr 10, 2010 at 7:31 PM, Charles R Harris wrote: > > > On Sat, Apr 10, 2010 at 6:17 PM, Gökhan Sever wrote: > >> Hello, >> >> Is there a simpler way to get "c" from "a" >> >> I[1]: a = np.arange(10) >> >> I[2]: b = a[3:] >> >> I[3]: b >> O[3]: array([3, 4, 5, 6, 7, 8, 9]) >> >> I[4]: c =

Re: [Numpy-discussion] Simple way to shift array elements

2010-04-10 Thread Charles R Harris
On Sat, Apr 10, 2010 at 6:17 PM, Gökhan Sever wrote: > Hello, > > Is there a simpler way to get "c" from "a" > > I[1]: a = np.arange(10) > > I[2]: b = a[3:] > > I[3]: b > O[3]: array([3, 4, 5, 6, 7, 8, 9]) > > I[4]: c = np.insert(b, [7]*3, 0) > O[5]: array([3, 4, 5, 6, 7, 8, 9, 0, 0, 0]) > > a an

Re: [Numpy-discussion] Simple way to shift array elements

2010-04-10 Thread Keith Goodman
On Sat, Apr 10, 2010 at 5:17 PM, Gökhan Sever wrote: > Hello, > > Is there a simpler way to get "c" from "a" > > I[1]: a = np.arange(10) > > I[2]: b = a[3:] > > I[3]: b > O[3]: array([3, 4, 5, 6, 7, 8, 9]) > > I[4]: c = np.insert(b, [7]*3, 0) > O[5]: array([3, 4, 5, 6, 7, 8, 9, 0, 0, 0]) > > a and

[Numpy-discussion] Simple way to shift array elements

2010-04-10 Thread Gökhan Sever
Hello, Is there a simpler way to get "c" from "a" I[1]: a = np.arange(10) I[2]: b = a[3:] I[3]: b O[3]: array([3, 4, 5, 6, 7, 8, 9]) I[4]: c = np.insert(b, [7]*3, 0) O[5]: array([3, 4, 5, 6, 7, 8, 9, 0, 0, 0]) a and c have to be same in length and the left shift must be balanced with equal nu