I have a time-series data as below:
print(df)
ric datel timel val
0 xyz 2017-01-01 09:00:00 2
1 xyz 2017-01-01 09:04:00 5
2 xyz 2017-01-01 09:37:00 6
Now I have to fill missing timestamps upto 09:45:00
.
Expected Output:
ric datel timel val
0 xyz 2017-01-01 09:00:00 2
1 xyz 2017-01-01 09:01:00 nan
2 xyz 2017-01-01 09:02:00 nan
3 xyz 2017-01-01 09:03:00 nan
4 xyz 2017-01-01 09:04:00 5
...
...
37 xyz 2017-01-01 09:37:00 6
...
...
45 xyz 2017-01-01 09:45:00 nan
What I tried:
df1=df.resample("1 min", on ='datel').first()
which gives output as:
ric datel timel val
datel
2017-01-01 xyz 2017-01-01 09:00:00 2
And also tried with pd.date_range
but it mostly works with datetime column.
I have two different columns date and time. Is there a way to achieve this without combining date and column into datetime?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…