Start Date | End Date |
---|---|
2020-02-14 | 2020-02-18 |
so the output column looks like
Start Date | End Date | Date_range |
---|---|---|
2020-02-14 | 2020-02-18 | [2020-02-14,2020-02-15,2020-02-16,2020-02-17,2020-02-18] |
CodePudding user response:
Use pd.date_range
:
date_range = lambda x: pd.date_range(x['Start Date'], x['End Date']).date.tolist()
df['Date_range'] = df.apply(date_range, axis=1)
print(df)
# Output
Start Date End Date Date_range
0 2020-02-14 2020-02-18 [2020-02-14, 2020-02-15, 2020-02-16, 2020-02-17, 2020-02-18]