Skip to content

ENH: add expanding window time support #16425

Open
@jreback

Description

@jreback

xref #16431

[5] should easily work. This is just disabled ATM.

In [1]: dft = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},
   ...:    ....:                    index = pd.Index([pd.Timestamp('20130101 09:00:00'),
   ...:    ....:                                      pd.Timestamp('20130101 09:00:02'),
   ...:    ....:                                      pd.Timestamp('20130101 09:00:03'),
   ...:    ....:                                      pd.Timestamp('20130101 09:00:05'),
   ...:    ....:                                      pd.Timestamp('20130101 09:00:06')],
   ...:    ....:                                     name='foo'))
   ...:                                     

In [2]: dft
Out[2]: 
                       B
foo                     
2013-01-01 09:00:00  0.0
2013-01-01 09:00:02  1.0
2013-01-01 09:00:03  2.0
2013-01-01 09:00:05  NaN
2013-01-01 09:00:06  4.0

In [4]: dft.rolling('2s').sum()
Out[4]: 
                       B
foo                     
2013-01-01 09:00:00  0.0
2013-01-01 09:00:02  1.0
2013-01-01 09:00:03  3.0
2013-01-01 09:00:05  NaN
2013-01-01 09:00:06  4.0

In [5]: dft.expanding('2s').sum()
ValueError: min_periods must be an integer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions