Hello,
I have a unbalanced panel data set of companies for which the monthly stock holdings data are available for a specific time period (say from 01/01/2003 - 01/06/2003). The data set looks like this.
I want want to fill the gaps in the dates to make it consecutive from 01/01/2003 to 01/06/2003 so the data should finally look like this.
I am unsure as to how I should use tsfill in this scenario (Is by group possible?). Any advice is highly appreciated
Thank you
I have a unbalanced panel data set of companies for which the monthly stock holdings data are available for a specific time period (say from 01/01/2003 - 01/06/2003). The data set looks like this.
Company | stock | date | qty | price |
A | 1 | 01/01/2003 | 4 | 25 |
A | 1 | 01/02/2003 | 5 | 30 |
A | 1 | 01/04/2003 | 2 | 22 |
A | 1 | 01/06/2003 | 6 | 31 |
A | 2 | 01/01/2003 | 2 | 2 |
A | 2 | 01/03/2003 | 4 | 4 |
A | 2 | 01/05/2003 | 8 | 3 |
A | 2 | 01/06/2003 | 2 | 5 |
B | 1 | 01/01/2003 | 1 | 45 |
B | 1 | 01/04/2003 | 6 | 42 |
B | 1 | 01/05/2003 | 8 | 41 |
B | 3 | 01/02/2003 | 21 | 13 |
B | 3 | 01/05/2003 | 10 | 11 |
B | 3 | 01/06/2003 | 8 | 21 |
Company | stock | date | qty | price |
A | 1 | 01/01/2003 | 4 | 25 |
A | 1 | 01/02/2003 | 5 | 30 |
A | 1 | 01/03/2003 | ||
A | 1 | 01/04/2003 | 2 | 22 |
A | 1 | 01/05/2003 | ||
A | 1 | 01/06/2003 | 6 | 31 |
A | 2 | 01/01/2003 | 2 | 2 |
A | 2 | 01/02/2003 | ||
A | 2 | 01/03/2003 | 4 | 4 |
A | 2 | 01/04/2003 | ||
A | 2 | 01/05/2003 | 8 | 3 |
A | 2 | 01/06/2003 | 2 | 5 |
B | 1 | 01/01/2003 | 1 | 45 |
B | 1 | 01/02/2003 | ||
B | 1 | 01/03/2003 | ||
B | 1 | 01/04/2003 | 6 | 42 |
B | 1 | 01/05/2003 | 8 | 41 |
B | 1 | 01/06/2003 | ||
B | 3 | 01/01/2003 | ||
B | 3 | 01/02/2003 | 21 | 13 |
B | 3 | 01/03/2003 | ||
B | 3 | 01/04/2003 | ||
B | 3 | 01/05/2003 | 10 | 11 |
B | 3 | 01/06/2003 | 8 | 21 |
Thank you
Comment