Numpy - add row to array
You can do this:
newrow = [1, 2, 3]
A = numpy.vstack([A, newrow])
What is X
? If it is a 2D-array, how can you then compare its row to a 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 to A
all rows from X
where the first element < 3
:
import numpy as np
A = np.vstack((A, X[X[:,0] < 3]))
# returns:
array([[0, 1, 2],
[0, 2, 0],
[0, 1, 2],
[1, 2, 0],
[2, 1, 2]])