Having an empty array
x = numpy.empty(0)
And two lists that looks like this
l1 = [1, 2, 3]
l2 = [4, 5, 6]
how do i add to the empty array the lists so that it becomes something like this
np.array([[1, 2, 3], [4, 5, 6])
instead of
np.array([1, 2, 3, 4, 5, 6])
which is what happens when i use
x = np.append(x, l1)
x = np.append(x, l2)
x = np.array([l1, l2]), and in case you need to append frequently, I would suggest appending it to a list and then convert to array when you need to.np.appendis more expensive thatlist.append.x = numpy.empty(0)in the first place?np.appendthe code will be:x = np.empty((0,3));x = np.append(x, [l1], axis=0);x = np.append(x, [l2], axis=0)appenddocs carefully.enough!