Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

numpy every nth element

silvio2402 answered on January 8, 2023 Popularity 6/10 Helpfulness 6/10

Contents


More Related Answers

  • python every nth element
  • numpy array with 2 times each value
  • numpy exclude every nth element

  • numpy every nth element

    1

    You can use numpy's slicing, simply start:stop:step.

    This creates a view of the the original data, so it's constant time. It'll also reflect changes to the original array and keep the whole original array in memory:

    so if either of the above things are a problem, you can make a copy explicitly:

    This isn't constant time, but the result isn't tied to the original array. The copy also contiguous in memory, which can make some operations on it faster.

    Popularity 6/10 Helpfulness 6/10 Language javascript
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Jan 08 2023
    silvio2402
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.