0
$\begingroup$

I have a dataframe which has two date columns - Start Date and End Date,

Let's suppose start date is 4/10/2019 and end date is 4/10/2020 (MM/DD/YYYY) now I want to split these dates in a list which will have all the intermediate months (from october 2019 to october 2020). Is there any function in python that can hep me with this?

$\endgroup$

1 Answer 1

0
$\begingroup$

You can likely use pandas.date_range as follows assuming your columns are called start and end:

import pandas as pd

df.apply(lambda x: pd.date_range(x["start"], x["end"]), axis=1)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.