way to add target delay on TimeseriesGenerator from keras.preprocessing.sequence from deep learning with python book, it created function for data generator.

I thought I can do the same using TimeseiresGenerator from keras package but I was not able to add target delay. Is there any way to do it?

EDIT: I found a way by using np.roll on target data. But if there is a better way please let me know.
You can use 


  pandas shift


By default the TimeseriesGenerator performs a lag of 1 timestep. Then, a workaraound is to create a pandas Series, and use the shift function. 
Let train be your sequence, and let forecast be an int representing the "size" of your lag. 

Eg:

label_train = pd.Series(train)    
train_generator = TimeseriesGenerator(train, label_train.shift(-forecast+1).values)


Obs: Be careful to pad your sequence after performing the lag.