I am trying to duplicate my pandas' data frame's rows and also adding an additional column for a time sequence in minutes between column FROM and TO.
For example, I have this data frame.
ID FROM TO
A 15:30 15:33
B 16:40 16:44
C 15:20 15:22
What I want the output to be is
ID FROM TO time
A 15:30 15:33 15:30
A 15:30 15:33 15:31
A 15:30 15:33 15:32
A 15:30 15:33 15:33
B 16:40 16:41 16:40
B 16:40 16:41 16:41
C 15:20 15:22 15:20
C 15:20 15:22 15:21
C 15:20 15:22 15:22
In R, I could do this: new_df = setDT(df)[, .(ID, FROM, TO, time=seq(FROM,TO,by="mins")), by=1:nrow(df)], but I am having trouble finding the Python equivalent of this.
Thank you in advance!