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
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]
2 Comments
sj95126
I have to admit being confused that the question asked about numpy and the accepted answer doesn't use it.
Mahdi F.
@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