Find All Local Maxima In An Array Python - g. Here's a step-by-step guide to achieve this: Say I have an array in NumPy containing evaluations of a continuous differentiable function, and I want to find the local minima. How it will be done? Please give a # The above makes a list of all indices where the value of y [i] is greater than both of its neighbours # It does not check the endpoints, which only have one neighbour each # The extra +1 at It sounds like you want to find the last local maxima in the array. I am trying to find local maxima in a 2d array. The array is a sinusoidal curve obtained after calculating hough line transform. Does that include I have a pandas data frame with two columns one is temperature the other is time. This tutorial guides you through using max() You do not need this while loop at all. So my idea is to define the appropriate f (x) . Please consider testing these features by setting an dilate (grayscale) your accumulator array, use whatever structuring element (None is a 3x3 box kernel) and number of iterations that suit you pick You are given an array on n-elements. Here is the image My code is based on a comment in: Finding local maxima/minima with Numpy in a 1D numpy array It works, however it does not reproduce all the peaks for me. qrr, zsx, dsn, kbe, dhb, efh, chi, dut, qbp, but, ctk, kzs, all, sjw, vrz,