jbn / ZigZag

Python library for identifying the peaks and valleys of a time series.
BSD 3-Clause "New" or "Revised" License
444 stars 178 forks source link

pandas compatability, type error #2

Closed distagon closed 2 years ago

distagon commented 7 years ago

pandas ver. 0.19.2

code: IBB = data.get_data_yahoo('IBB') X = IBB['Adj Close'] pivots = peak_valley_pivots(X, 0.2, -0.2) ts_pivots = pd.Series(X, index=X.index) ts_pivots = ts_pivots[pivots != 0] X.plot() ts_pivots.plot(style='g-o')

error msg: TypeError Traceback (most recent call last)

in () 13 IBB = data.get_data_yahoo('IBB') 14 X = IBB['Adj Close'] ---> 15 pivots = peak_valley_pivots(X, 0.2, -0.2) 16 ts_pivots = pd.Series(X, index=X.index) 17 ts_pivots = ts_pivots[pivots != 0] D:\Progs\Anaconda3\lib\site-packages\numba\dispatcher.py in _explain_matching_error(self, *args, **kws) 353 msg = ("No matching definition for argument type(s) %s" 354 % ', '.join(map(str, args))) --> 355 raise TypeError(msg) 356 357 def _search_new_conversions(self, *args, **kws): TypeError: No matching definition for argument type(s) pyobject, float64, float64
distagon commented 7 years ago

following works: pivots = peak_valley_pivots(X.values, 0.2, -0.2)

So, peak_valley_pivots() input must be np.array, can't be pandas series?

jbn commented 7 years ago

Yes. I remember that happening at some point, and I never fixed it.

The X.values hack works for now. But, I'm going to keep this open. I think this code needs a refactor, in general.

jbn commented 2 years ago

0.3.0 now allows you to just call peak_valley_pivots with the pd.Series object