Suppose i have an array A of length n I want a variable b to be an array consisting of the first k elements of A and variable c to be an array with the last n-k elements of A. How do you do this? Example A = np.array([1,2,3,4,5,6]), k = 2 b = [1,2] c=[3,4,5,6] Thanks. -- View this message in context: http://old.nabble.com/basic-numpy-array-operation-tp27908290p27908290.html Sent from the Numpy-discussion mailing list archive at Nabble.com.
On Mon, Mar 15, 2010 at 13:20, gerardo.berbeglia
Suppose i have an array A of length n I want a variable b to be an array consisting of the first k elements of A and variable c to be an array with the last n-k elements of A.
How do you do this?
Example A = np.array([1,2,3,4,5,6]), k = 2 b = [1,2] c=[3,4,5,6]
b = A[:2] c = A[2:] -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
participants (2)
-
gerardo.berbeglia
-
Robert Kern