tidypyverse / tidypandas

A grammar of data manipulation for pandas inspired by tidyverse
https://tidypyverse.github.io/tidypandas/
MIT License
91 stars 7 forks source link

[pondering] Should `mutate` handle sliding window operations? #13

Open talegari opened 2 years ago

talegari commented 2 years ago

First thoughts:

df.mutate({'rolling_3_sum': (np.sum, 'col_1')}, window = [-1, 1])

-1: start at one index before 1: end at one index after


df.mutate({'rolling_3_sum': lambda x: (x['col_1'] + x['col_2'])/2}, window = [-1, 1])

we should be having the entire dataframe context here.


https://davisvaughan.github.io/slider/ https://dbplyr.tidyverse.org/articles/translation-function.html#window-functions https://pandas.pydata.org/docs/user_guide/window.html