Let's say I have an Employees Table and yearly survey filled by each person. I have to transform transactional data into prediction data year wise.
Available Data:
| E_ID | TestYear | DateOfBirth |
|---|---|---|
| 1 | 2010 | 1947-01-01 |
| 1 | 2011 | 1947-01-01 |
| 1 | 2012 | 1947-01-01 |
| 2 | 2010 | 1990-01-01 |
| 3 | 2011 | 1999-01-01 |
| 4 | 2011 | 1991-01-01 |
| 4 | 2012 | 1991-01-01 |
| 5 | 2010 | 1989-01-01 |
| 5 | 2011 | 1989-01-01 |
| 5 | 2012 | 1989-01-01 |
| 5 | 2013 | 1989-01-01 |
DataFrame I need:
| E_ID | Year | Age |
|---|---|---|
| 1 | 2010 | 63 |
| 1 | 2011 | 64 |
| 1 | 2012 | 65 |
| 2 | 2010 | 20 |
| 2 | 2011 | 21 |
| 2 | 2012 | 22 |
| 3 | 2010 | 11 |
| 3 | 2011 | 12 |
| 3 | 2012 | 13 |
| 4 | 2010 | 19 |
| 4 | 2011 | 20 |
| 4 | 2012 | 21 |
| 5 | 2010 | 21 |
| 5 | 2011 | 22 |
| 5 | 2012 | 23 |
In the new df I need all employees, for all 3 years 2010, 2011, 2022 and their relevant ages in the year 2010, 2011, 2022 respectively.
How to achieve this? Since in the transactional data, I have records for some employees for some years and not for other years.