Skip to content
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

Poisson (exponential) window for pandas.Series.rolling #21303

Closed
stroobandt opened this issue Jun 3, 2018 · 2 comments

Comments

@stroobandt
Copy link

commented Jun 3, 2018

Problem Description

In pandas.Series.rolling, the SciPy window type exponential has not been implemented. This win_type would be extremely useful for analysing biological processes. It should be pretty easy to add.

Please, note that despite the similar name, the proposed method is mathematically different from the implemented pandas.Series.ewm method.

Enhancement Request

Taking for example df.rolling(51, win_type='exponential', tau=10), the implemented SciPy window would be the following asymmetrical window:

from scipy import signal
window = 51
tau = 10
w = signal.exponential(window, tau=tau, sym=False, center=0)
array([1.        , 0.90483742, 0.81873075, 0.74081822, 0.67032005,
       0.60653066, 0.54881164, 0.4965853 , 0.44932896, 0.40656966,
       0.36787944, 0.33287108, 0.30119421, 0.27253179, 0.24659696,
       0.22313016, 0.20189652, 0.18268352, 0.16529889, 0.14956862,
       0.13533528, 0.12245643, 0.11080316, 0.10025884, 0.09071795,
       0.082085  , 0.07427358, 0.06720551, 0.06081006, 0.05502322,
       0.04978707, 0.0450492 , 0.0407622 , 0.03688317, 0.03337327,
       0.03019738, 0.02732372, 0.02472353, 0.02237077, 0.02024191,
       0.01831564, 0.01657268, 0.01499558, 0.01356856, 0.01227734,
       0.011109  , 0.01005184, 0.00909528, 0.00822975, 0.00744658,
       0.00673795])

Expected Output

>>> df = pd.DataFrame({'B': [1, 0, 0, 0, 0]})
>>> df.rolling(51, win_type='exponential', tau=10)
     B
0  1.0
1  0.90483742
2  0.81873075
3  0.74081822
4  0.67032005
@jreback

This comment has been minimized.

Copy link
Contributor

commented Jun 3, 2018

we already support scipy types so this would be very easy to add - a pull request would make this happen
http://pandas.pydata.org/pandas-docs/stable/computation.html#rolling-windows

@stroobandt

This comment has been minimized.

Copy link
Author

commented Jun 3, 2018

As far as I can see, only these files need to be amended:

  • pandas/pandas/core/window.py
  • pandas/pandas/tests/test_window.py
  • pandas/doc/source/computation.rst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.