Skip to content

Instantly share code, notes, and snippets.

@ken333135
Created June 17, 2019 07:49
Show Gist options
  • Save ken333135/6d7fa3da4955353eec3b1d37f78c85b7 to your computer and use it in GitHub Desktop.
Save ken333135/6d7fa3da4955353eec3b1d37f78c85b7 to your computer and use it in GitHub Desktop.
def date_generator(from_date,to_date):
while from_date<=to_date:
yield from_date
from_date = from_date + dt.timedelta(days=1)
# create a new df with 2 columns
# col1 : Title, col2: DateRead
Title = []
Date = []
for index,row in booksv2.iterrows():
date_temp = list(date_generator(row['Start'],row['End']))
title_temp = [row['Title']]*len(date_temp)
print(date_temp,title_temp)
Title += title_temp
Date += date_temp
booksv2 = pd.DataFrame(np.array([Title,Date]),index=['Title','Date']).T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment