Hi,

Sorry for the vague question.

**I have about a dozend implementations of that in numpy. So I am not looking for “one possible way to do it”.**

But I know that I found somewhere on the internet ( I think it was either here or on StackOverflow) a beautiful “one liner” solution in PyTorch and thought “awesome, will try that later”. And I can’t find it again even after an hour googling or going through my history.

Problem:

given a1D tensor/array (time series) and a desired lag/window length (let’s say window length = 2)

[x1, x2, x3, x4…]

I want to get to a 2D tensor, each row the current value and the n lags:

[x1,x2,x3]

[x2,x3,x4]

[x3,x4,x5]

…

There are oviously many ways to do that. But I think I recall it was either a single function or maybe a clever one-line combination of reshape and other functions. But I think it was a single function call.

It drives me mad that I can’t find the particular post again. Anybody an idea?

Thanks!!