I have a dataframe with a column named DateTime with datetime values populated every 5 seconds. But few rows are missing which can be identified by seeing time difference between previous and current row. I want to insert the missing rows and populate other column with previous row values.
My Sample dataframe is like below:
DateTime Price
2022-03-04 09:15:00 34526.00
2022-03-04 09:15:05 34487.00
2022-03-04 09:15:10 34470.00
2022-03-04 09:15:20 34466.00
2022-03-04 09:15:45 34448.00
Result dataframe as below:
DateTime Price
2022-03-04 09:15:00 34526.00
2022-03-04 09:15:05 34487.00
2022-03-04 09:15:10 34470.00
2022-03-04 09:15:15 34470.00 <----Insert Row and keep Price same as previous row
2022-03-04 09:15:20 34466.00
2022-03-04 09:15:25 34466.00 <----Insert Row and keep Price same as previous row
2022-03-04 09:15:30 34466.00 <----Insert Row and keep Price same as previous row
2022-03-04 09:15:35 34466.00 <----Insert Row and keep Price same as previous row
2022-03-04 09:15:40 34466.00 <----Insert Row and keep Price same as previous row
2022-03-04 09:15:45 34448.00