假设我有一个包含4列的数据框,并且当我滚动的窗口大小为k时,是否有办法确保我在每个滚动窗口中都有所有列?
d = pd.DataFrame({
'x':[1,2,3,4,5],
'y':[5,4,3,2,1],
'r':[2,3,4,5,6],
'q':[1,2,8,9,0]
})
# Doing this does not work!!!
d.rolling(window=3,axis=0)
例如,我假设window = 2,我想滚动返回每三个窗口切片的所有x,y,r,q列
切片#1
[1,5,2,1],
[2,4,3,2]
切片#2
[2,4,3,2],
[3,3,4,8]
依此类推