Skip to content

Instantly share code, notes, and snippets.

@ken333135
Created June 17, 2019 07:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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