Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python NumPy delete Function Example Deletion performed using Boolean Mask

# welcome to softhunt.net
# Python Program illustrating
# numpy.delete()

import numpy as np

arr = np.arange(5)
print("Original array : ", arr)
mask = np.ones(len(arr), dtype=bool)

# Equivalent to np.delete(arr, [0,2,4], axis=0)
mask[[0,2]] = False
print("
Mask set as : ", mask)
result = arr[mask,...]
print("
Deletion Using a Boolean Mask : ", result)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #NumPy #delete #Function #Example #Deletion #performed #Boolean #Mask
ADD COMMENT
Topic
Name
6+4 =