I am a beginner to Data Science and I am working on 2 datasets which consists of A and B column
A B
0 2019-03-13 08:12:20 2019-03-13 08:12:25
1 2019-03-15 10:02:18 2019-03-13 10:02:20
I am trying to generate a range of seconds between the A column and the B column. As an output I need to get this:
A
0 2019-03-13 08:12:20
1 2019-03-13 08:12:21
2 2019-03-13 08:12:22
3 2019-03-13 08:12:23
4 2019-03-13 08:12:24
5 2019-03-13 08:12:25
I achieved it by giving the code below but it takes a lot of time since there are around 1M rows. Can anyone suggest to me which is the best way to do it?
import pandas as pd, numpy as np
df=pd.DataFrame({'A': ["2019-03-13 08:12:20", "2019-03-15 10:02:18"], 'B': ["2019-03-13 08:12:25", "2019-03-13 10:02:20"]})
l=[pd.date_range(start=df.iloc[i]['A'], end=df.iloc[i]['B'], freq='S') for i in range(len(df))]
df1=(pd.DataFrame(l).T)[0]
print(df1)