 def shift_timeseries_by_lags(df, lags, lag_label='lag'): return pd.concat([ shift_timeseries_and_create_multiindex_column(df, lag, lag_label=lag_label) for lag in lags], axis=1) def shift_timeseries_and_create_multiindex_column( dataframe, lag, lag_label='lag'): return (dataframe.shift(lag) .pipe(append_level_to_columns_of_dataframe, lag, lag_label))