Hihi, I'm reasonably new to Python, more a R guy. But I'm required to use python for a task.
However, I encountered a situation where I need to subset data into different dataFrame by the date. "in future not 3 exactly, therefore want to create a loop to do this" I want to potentially create 3 dataframes like
df_train_30 which contains start day 0 - 30
df_train_60 which contains start day 30 - 60
df_train_90 which contains start day 60 - 90
but not sure how to achieve this... pls help.
idea in code below
today = pd.to_datetime('now')
df_train['START_DATE'] = pd.to_datetime(df_train['START_DATE'])
previous_day_del = 0
for day_del in (30,60,90):
**'df_train_' + str(day_del)** = df_train[(df_train['START_DATE']>= today - timedelta(days=day_del)) & (df_train['START_DATE']< today - timedelta(days=previous_day_del))]
previous_day_del = day_del