Reputation: 2785
Say we have an incoming stream of data of size (1,N), it is a numpy array
read_data = [[foo, foo_1, foo_2]]
And we want to do something with that or simply append it to a larger array.
data=np.vstack((data,real_data)) (or whatever method you choose)
My trouble usually comes in the fact that I do not know the dimensions of the incoming data, so what I sometimes do, is:
In matlab this is very easy, since it dynamically creates the array you need as soon as you give data (although is not recommended to do)
What is the best way to do it in python?
Upvotes: 5
Views: 6510
Reputation: 3967
I think a good option is:
import numpy
first_array = numpy.array([1,2,3])
new_array = numpy.append(first_array, [4,5,6])
print new_array
And the output is: [1 2 3 4 5 6]
Upvotes: 2