pandas python

Selecting local minima and maxima from pandas.Series

There is a scipy.signal.argrelextrema function that works with ndarray, but when I try to use it on pandas.Series, it returns an error. What’s the right way to use it with pandas?

import numpy as np
import pandas as pd
from scipy.signal import argrelextrema
s = pd.Series(randn(10), range(10))
argrelextrema(s, np.greater)
TypeError Traceback (most recent call last)
<ipython-input-13-f3812e58bbe4> in <module>()
4 s = pd.Series(randn(10), range(10))
5 s
----> 6 argrelextrema(s, np.greater)
/usr/lib/python2.7/dist-packages/scipy/signal/_peak_finding.pyc in argrelextrema(data, comparator, axis, order, mode)
222 """
223 results = _boolrelextrema(data, comparator,
--> 224 axis, order, mode)
225 return np.where(results)
/usr/lib/python2.7/dist-packages/scipy/signal/_peak_finding.pyc in _boolrelextrema(data, comparator, axis, order, mode)
61 results = np.ones(data.shape, dtype=bool)
---> 62 main = data.take(locs, axis=axis, mode=mode)
63 for shift in xrange(1, order + 1):
64 plus = data.take(locs + shift, axis=axis, mode=mode)
TypeError: take() got an unexpected keyword argument 'mode'