-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: recurrence relation calculations #4567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here a python function solving this partly:
and can be called like:
Maybe a hack from performance point but works ;-) |
I think it's important to make a recurrent relation apply to an entire data frame and not just a single series, otherwise this enhancement becomes equivalent to the |
of course, that is just an example of the impl; should for sure handle 2-d |
Or even n-dimensions. The recurrence relation could take (n-1)-dimensional slices of the data frame along the remaining dimension and provide the designated |
you could do that with a custom function, when I mean 2-d I mean it basically respects the axis parameter, like apply |
Should get a working 1d version before we start generalizing |
This would be a great piece. I use talib to do tons of financial calculations that are recurrence relations |
this could be neat, but probably should live outside of pandas |
these are actually trivially implemented with numba :-> |
@jreback would you elaborate how these are trivially implemented with numba? |
look in the window functions we already have ewm implemented this way |
I think an implementation of a general recurrent relation might be interesting. These
are not able to evaluated in numpy/numexpr directly
see here:
http://stackoverflow.com/questions/9984373/calculate-two-coupled-equation-with-numpy
http://stackoverflow.com/questions/21336794/python-recursive-vectorization-with-timeseries/21338665
http://stackoverflow.com/questions/23996260/python-pandas-using-the-previous-value-in-dataframe/23997030#23997030
in the case where a(i) and b(i) are constants then this can be completely cythonized
if a and/or b are passed functions then the shell can still be cythonized (with the function called at each iteration)
Example
I propose that pandas have a
recurrence
wrapper (that can then call a pure constant cython version and a cython version that takes functions)Probably just for a 1-dim array atm
In theory this can also be done by a
rolling_apply
that has memory (or I guess that is sort of the same thing)related #4546
https://groups.google.com/forum/#!topic/pydata/0MCWhwurOWs
The text was updated successfully, but these errors were encountered: