Write a NumPy program to remove specific elements in a NumPy array.
import numpy as np x = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) index = [0, 3, 4] print("Original array:") print(x) print("Delete first, fourth and fifth elements:") new_x = np.delete(x, index) print(new_x)
Sample Output:
Original array: [ 10 20 30 40 50 60 70 80 90 100] Delete first, fourth and fifth elements: [ 20 30 60 70 80 90 100]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer