Skip to content

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

Closed
@stroobandt

Description

@stroobandt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeWindowrolling, ewma, expanding

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions