Pandas 3.0 rolling will add support to first and last natively. However, as of writing of this answer this is still in dev branch:
first
last
https://pandas.pydata.org/docs/dev/reference/api/pandas.core.window.rolling.Rolling.last.html#pandas.core.window.rolling.Rolling.last