I have one date column which has timeseries data for every minute. I want to update my all other columns to also have data for every minute, so Date2 and Date3 columns should have same values as Date column. I also want columns Value1(linked to Date 2 column) and Value2 (linked to Date3 column), to have values filled so that each row has value. Filling should replace always the latest value visible.
For example columnn Date2 row 2019-01-30 10:05, corresponding column Value1, same row should have value 3 as that wast the last updated value for stamp 10:04.
Finally for Date column all dates which are older than for columns Date2 and Date3 column should be removed. Here row 2019-01-30 10:03.
Date Date2 Value1 Date3 Value2
2019-01-30 10:09 2019-01-30 10:08 1 2019-01-30 10:07 5
2019-01-30 10:08 2019-01-30 10:07 2 2019-01-30 10:04 9
2019-01-30 10:07 2019-01-30 10:06 4
2019-01-30 10:06 2019-01-30 10:04 3
2019-01-30 10:05
2019-01-30 10:04
2019-01-30 10:03
Result should be:
Date Date2 Value1 Date3 Value2
2019-01-30 10:09 2019-01-30 10:09 1 2019-01-30 10:09 5
2019-01-30 10:08 2019-01-30 10:08 1 2019-01-30 10:08 5
2019-01-30 10:07 2019-01-30 10:07 2 2019-01-30 10:07 5
2019-01-30 10:06 2019-01-30 10:06 4 2019-01-30 10:06 9
2019-01-30 10:05 2019-01-30 10:05 3 2019-01-30 10:05 9
2019-01-30 10:04 2019-01-30 10:04 3 2019-01-30 10:04 9
It seems you want to have the same values of dates in all columns of date, right? If yes then you just copy Date to Date2 and Date3. When you read columns using Pandas, the missing values are read as 'NAN' which you can replace with DataFrame.fillna.
If you have already read columns and want them filled, a naive method would be to use columns as NumPy arrays: