# NumPy delete - Delete the items from an array

The item of a NumPy array can be deleted or removed by delete method.

import numpy

a = numpy.array([3, 4, 5, 6])

b = numpy.delete(a, 1)
c = numpy.delete(a, 2)
d = numpy.delete(a, 3)

print(b)  # [3 5 6]
print(c)  # [3 4 6]
print(d)  # [3 4 5]


The argument is index. The item of index 2 in a is 5, so c is [3 4 6]. The argument can be a list.

import numpy

a = numpy.array([3, 4, 5, 6])

b = numpy.delete(a, [0, 1])
c = numpy.delete(a, [1, 3])

print(b)  # [5 6]
print(c)  # [3 5]


If the index is out of range, Python raises IndexError exception.

import numpy

a = numpy.array([3, 4, 5, 6])

b = numpy.delete(a, [6, 3])

print(b)
# IndexError: index 6 is out of bounds for axis 0 with size 4