def root2(df, shift):
    return pd.concat([df.iloc[-shift:], df.iloc[:-shift]])

def ed_chum(df, num):
    return pd.DataFrame(np.roll(df, num, axis=0), np.roll(df.index, num),
        columns=df.columns)

def divakar1(df, shift):
    return df.iloc[np.roll(np.arange(df.shape[0]), shift)]

def divakar2(df, shift):
    idx = np.mod(np.arange(df.shape[0]) - 1, df.shape[0])
for _ in range(shift):
    df = df.iloc[idx]
return df
Циклически сдвигать фрейм данных pandas вниз