<jupyter_start><jupyter_text>Add Elements to a NumPy Array<jupyter_code>import numpy as np
nums = np.arange(5)

print(nums)<jupyter_output>[0 1 2 3 4]<jupyter_text>Add Items or Combine Arrays<jupyter_code>new_nums = np.append(nums, 5)

print(nums)
print(new_nums)
new_nums = np.concatenate([ nums, [5], [6,7,8], [9, 10] ])

print(nums)
print(new_nums)<jupyter_output>[0 1 2 3 4]
[ 0  1  2  3  4  5  6  7  8  9 10]<jupyter_text>Insert an Item into an Array<jupyter_code>new_nums = np.insert(nums, 2, 9)

print(nums)
print(new_nums)<jupyter_output>[0 1 2 3 4]
[0 1 9 2 3 4]
StarcoderdataJupyterStructuredCleanDedup