Reputation: 385
I want to create a numpy array of a set size. I have a numpy array containing 4 numbers. My question right now is how to fill the array with zeros till an arbitrary size e.g. 7 in this example
pos = np.array([1,4,6,8])
new_pos = np.array([1,4,6,8,0,0,0])
Upvotes: 2
Views: 2477
Reputation: 1276
np.zeros(5) # returns array([ 0., 0., 0., 0., 0.])
new_pos = pos.append(np.zeros(5))
5 has been used arbitrarily. In your case it will be 3.
Upvotes: 4