I have a dataset which contains two columns of “Time” and “traffic”. I’m trying to use windowing when feeding data to LSTM, using this code:
df=df.iloc[:,1:3]
vek=pd.DataFrame() # Create an empty DataFrame named 'vek'
yr=np.array([]) # Create an empty NumPy array named 'yr'
for i in range(2004,2006):
for j in range(1,13): # Loop through the months 1 to 12
Time=str(i)+"_"+str(j) # Create a string in the format "year_month"
yr=np.append(yr,[Time])
tefe=np.array(df.iloc[:1,:3]) #Extracts the first row and the first 2 columns of the DataFrame df and converts it into a NumPy array called tefe
for k in range(2005,2006):
m=k-2004
n=k-2003
tefe=np.concatenate([tefe,np.array(df.iloc[m:n,:3])],axis=1)
yr=yr.T #Transposes the 'yr' array.
cf = pd.DataFrame(tefe.T, columns = ["Yearly Traffic"], index = yr) #Creates a new Pandas DataFrame named cf using the transposed tefe array.
cf=cf.dropna() #Drops any rows in the DataFrame cf that contain missing values.
print(cf)
and it gives me the following error: ValueError: Shape of passed values is (2, 1), indices imply (24, 1)
could you tell me please how to resolve this error?