1

For example if my array is X= [1,2,3,4,5,6,7,8,9,10]. And I want to select the every element except those at 6,7,8. is there an efficient way to do it? ( my array is actually 200 element wide and I need to select elements from a sliding window of 150 elements)

1 Answer 1

2

You can use [:end] + [start:] like below:

>>> x = [1,2,3,4,5,6,7,8,9,10]
>>> x[:4] + x[7:]
[1, 2, 3, 4, 8, 9, 10]
Sign up to request clarification or add additional context in comments.

2 Comments

I have to admit being confused that the question asked about numpy and the accepted answer doesn't use it.
@sj95126 you are right, but numpy as part of python and you can solve with original python, and you can edit question. I edit question because you say very right

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.