I need to select the data frame using my train period shown below but it ran into error always.
train_period = [ ['1/1/2018', '10/30/2018']] train_period = [[datetime.strptime(y,'%m/%d/%Y') for y in x] for x in train_period] for tp in train_period: print() #print('Begin:%d End:%d' % (tp[0], tp[1])) print() df_train_period = df_sku[ (df_sku['To_Date'] >= tp[begin]) & (df_sku['To_Date'] <= tp[end])]
df_sku['To_Date'].dtypeshow? You may need to convert it tonp.datetimedf_sku['To_Date'] = pd.to_datetime(df_sku, format='%m/%d/%Y')and then try your code