python - Numpy - add row to array -


how 1 add rows numpy array?

i have array a:

a = array([[0, 1, 2], [0, 2, 0]]) 

i wish add rows array array x if first element of each row in x meets specific condition.

numpy arrays not have method 'append' of lists, or seems.

if , x lists merely do:

for in x:     if i[0] < 3:         a.append(i) 

is there numpythonic way equivalent?

thanks, s ;-)

what x? if 2d-array, how can compare row number: i < 3?

edit after op's comment:

a = array([[0, 1, 2], [0, 2, 0]]) x = array([[0, 1, 2], [1, 2, 0], [2, 1, 2], [3, 2, 0]]) 

add a rows x first element < 3:

a = vstack((a, x[x[:,0] < 3]))  # returns:  array([[0, 1, 2],        [0, 2, 0],        [0, 1, 2],        [1, 2, 0],        [2, 1, 2]]) 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -