'How to fill gaps between two rows having the difference expressed in days
I have the following dataframe where diff_days is the difference between one row and the previous row
+----------+--------+---------+
| fx_date| col_1 |diff_days|
+----------+--------+---------+
|2020-01-05| A| null|
|2020-01-09| B| 4|
|2020-01-11| C| 2|
+----------+--------+---------+
I want to get a dataframe adding rows with missing dates and replicated values of col_1 related to the first row.
It should be:
+----------+--------+
| fx_date| col_1 |
+----------+--------+
|2020-01-05| A|
|2020-01-06| A|
|2020-01-07| A|
|2020-01-08| A|
|2020-01-09| B|
|2020-01-10| B|
|2021-01-11| C|
+----------+--------+
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
