JeffreySarnoff / RollingFunctions.jl

Roll a window over data; apply a function over the window.
MIT License
117 stars 7 forks source link

Option to pad initial values to preserve length? #19

Closed pdeffebach closed 3 years ago

pdeffebach commented 3 years ago

Came up on discourse. Someone has a DataFrame,

df = DataFrame(y = [1, 2, 3, 4, 5, 6])

and they want to add a new column z where z = rolling(sum, df.y, 2).

Unfortunately, this gives a 5 element vector, so you can't use transform from DataFrames.

Can we add a keyword argument to add padding? Could hurt performance because it would change the type of output... but could be a good option to have.

JeffreySarnoff commented 3 years ago

Does it not already? Or have I misunderstood your intent?

Compare "rolling" with "running"

https://github.com/JeffreySarnoff/RollingFunctions.jl#rolling-a-function-over-data

https://github.com/JeffreySarnoff/RollingFunctions.jl#running-a-function-over-data

JeffreySarnoff commented 3 years ago

glad it is available