Home > Software engineering >  How to select multiple intervals from an array in numpy?
How to select multiple intervals from an array in numpy?

Time:10-20

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)

CodePudding user response:

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]
  • Related