Selecting local minima and maxima from pandas.Series
Even though s.values
still works fine (Pandas 0.25), the recommended way is now:
argrelextrema(s.to_numpy(), np.greater)
# equivalent to:
argrelextrema(s.to_numpy(copy=False), np.greater)
While there is also an s.array
property, using it here will fail with: TypeError: take() got an unexpected keyword argument 'axis'
.
Note: copy=False
means "don't force a copy", but it can still happen.
You probably want to use it like so,
argrelextrema(s.values, np.greater)
You are currently using the complete pandas Series while argrelextrema expects an nd array. s.values provides you with the nd.array