I'd like to split my time-series data into X and y by shifting the data. The dummy dataframe looks like:
i.e. if the time steps equal to 2, X and y look like: X=[3,0] -> y= [5]
X=[0,5] -> y= [7] (this should be applied to the entire samples (rows))
I wrote the function below, but it returns empty matrices when I pass pandas dataframe to the function.
def create_dataset(dataset, time_step=1):dataX, dataY = [], []for i in range (len(dataset)-time_step-1): a = dataset.iloc[:,i:(i+time_step)] dataX.append(a) dataY.append(dataset.iloc[:, i + time_step ])return np.array(dataX), np.array(dataY)
Thank you for any solutions.