“I have two tables that need to be combined. One table contains basic information about deals and another table information about the associated products.Each row consists of a state a deal was in from Start Date Deal to End Date Deal. If one of the attributes changes, I have a new row with the new information and the date range for which this information held true. The same applies to the products table.”
#deals
"Start Date Deal,End Date Deal,Deal attributes\n1.1.2021,1.2.2021,status 1\n2.2.2021,3.3.2021,status 2\n4.3.2021,15.6.2021,status 3\n"
#products
"Product ID,Start Date Product,End Date Product,Product attributes\n234,15.1.2021,2.2.2021,Price 1\n234,3.2.2021,15.6.2021,Price 2\n456,15.1.2021,4.2.2021,Price 5\n456,5.2.2021,10.6.2021,Price 6\n"
In order to work with the data, I need a table that contains the information from both tables. The problem is that I have Date Ranges and this approach should be robust to this.
#result
"Product ID,Start Date Phase,End Date Phase,Deal attributes,Product attributes\n234,1.1.2021,14.1.2021,status 1,\n234,15.1.2021,1.2.2021,status 1,Price 1\n234,2.2.2021,2.2.2021,status 2,Price1\n234,3.2.2021,3.3.2021,status 2,Price 2\n234,4.3.2021,15.6.2021,status 3,Price 2\n456,1.1.2021,14.1.2021,status 1,\n456,15.1.2021,1.2.2021,status 1,Price 5\n456,2.2.2021,4.2.2021,status 2,Price 5\n456,5.2.2021,3.3.2021,status 2,Price 6\n456,4.3.2021,10.6.2021,status 3,Price 6\n456,11.6.2021,15.6.2021,status 3,\n"
julia> result
11×5 DataFrame
Row │ Product ID Start Date Phase End Date Phase Deal attributes Product attributes
│ Any Any Any Any Any
─────┼───────────────────────────────────────────────────────────────────────────────────
1 │ 234 1.1.2021 14.1.2021 status 1 missing
2 │ 234 15.1.2021 1.2.2021 status 1 Price 1
3 │ 234 2.2.2021 2.2.2021 status 2 Price1
4 │ 234 3.2.2021 3.3.2021 status 2 Price 2
5 │ 234 4.3.2021 15.6.2021 status 3 Price 2
6 │ 456 1.1.2021 14.1.2021 status 1 missing
7 │ 456 15.1.2021 1.2.2021 status 1 Price 5
8 │ 456 2.2.2021 4.2.2021 status 2 Price 5
9 │ 456 5.2.2021 3.3.2021 status 2 Price 6
10 │ 456 4.3.2021 10.6.2021 status 3 Price 6
11 │ 456 11.6.2021 15.6.2021 status 3 missing