Python (numpy): removing columns by index

I have a numpy array and you want to delete some columns based on the index. Is there a built-in function for it, or some elegant way for such an operation?

Sort of:

arr = [234, 235, 23, 6, 3, 6, 23]
elim = [3, 5, 6]

arr = arr.drop[elim]

output: [234, 235, 23, 3]
+5
source share
1 answer

use numpy.delete, it will return a new array:

import numpy as np
arr = np.array([234, 235, 23, 6, 3, 6, 23])
elim = [3, 5, 6]
np.delete(arr, elim)
+9
source

All Articles