7

I've got a numpy array and would like to remove some columns based on index. Is there an in-built function for it or some elegant way for such an operation?

Something like:

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

arr = arr.drop[elim]

output: [234, 235, 23, 3]

1 Answer 1

11

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.