Q:

Write a NumPy program to remove specific elements in a NumPy array

0

Write a NumPy program to remove specific elements in a NumPy array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now