Skip to content

Is it possible to perform a rolling linear regression with Vaex? #1829

Answered by maartenbreddels
LamBadaMan asked this question in Q&A
Discussion options

You must be logged in to vote

Interesting question. I don't think this will give stellar performance, but it may be a good first start:

import vaex
import numpy as np
x = np.arange(100)
df = vaex.from_arrays(x=x)
df2 = df.rolling(10, fill_value=0).array()
print(df2)
==== output ====
#    x
0    array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
1    array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
2    array([0, 0, 0, 0, 0, 0, 0, 0, 1, 2])
3    array([0, 0, 0, 0, 0, 0, 0, 1, 2, 3])
4    array([0, 0, 0, 0, 0, 0, 1, 2, 3, 4])
5    array([0, 0, 0, 0, 0, 1, 2, 3, 4, 5])
6    array([0, 0, 0, 0, 1, 2, 3, 4, 5, 6])
7    array([0, 0, 0, 1, 2, 3, 4, 5, 6, 7])
8    array([0, 0, 1, 2, 3, 4, 5, 6, 7, 8])
9    array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
...  .…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LamBadaMan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants