Feature request: first & last for rolling() · Issue #33155 · pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example if possible

This works:

df1 = df.resample(to_freq, closed='left', kind='period', ).agg(OrderedDict([('Open', 'first'), ('Close', 'last'), ]))

This doesn't:

df2 = df.rolling(my_indexer).agg( OrderedDict([('Open', 'first'), ('Close', 'last') ]))

AttributeError: 'first' is not a valid function for 'Rolling' object

df3 = df.rolling(my_indexer).agg( OrderedDict([ ('Close', 'last') ]))

AttributeError: 'last' is not a valid function for 'Rolling' object

Please, could 'first' and 'last' be made available for rolling window?
Thanks for your support!
Bests,