Table 1
Category Date Value
A 01/01/2015 4
A 02/01/2015 1
B 01/01/2015 6
B 02/01/2015 7
Table 1 above has the values for each category organized by month.
Table 2
Category Date Value
A 03/01/2015 10
C 03/01/2015 66
D 03/01/2015 9
Suppose table 2 comes in, which has the values for each category in March, 2015.
Table 3
Category Date Value
A 01/01/2015 4
A 02/01/2015 1
A 03/01/2015 10
B 01/01/2015 6
B 02/01/2015 7
B 03/01/2015 0
C 01/01/2015 0
C 02/01/2015 0
C 03/01/2015 66
D 01/01/2015 0
D 02/01/2015 0
D 03/01/2015 9
I want to "outer-join" the two tables "vertically" on Python: If Table2 has a category that Table1 doesn't have, then it adds that category to Table3 and assign a value of 0 for 01/01/2015 and 02/01/2015. Also, the category that is in table1 but not in table2 will also be added in table 3, by assigning a value of 0 for 03/01/2015. If both have the same categories, they will just be added vertically with the values in the table1 and table2.
Any advice or help will be greatly appreciated.. I've been thinking about this all day and still can't find an efficient way to do this. Thanks so much!
itertools.product().