Need help . (pls direct to other solution if already answered, couldn't find a relevant one)
In a work schedule of employees like :
EMP_COUNT TYPE startdate enddate
1 5 REGULAR 1/1/2014 3/15/2014
2 2 OVERTIME 1/7/2014 1/10/2014
3 5 MONTHEND 3/16/2014 3/31/2014
4 2 OVERTIME 3/30/2014 3/31/2014
I want to create another dataframe from above aggregated EMP count , constraints are ;
Total rows to be created for each schedule are to match EMP Count. A unique ID need to be created for each start date and end date duration arching 1 or more schedules, say 1 to 5. Then if any other schedule date is within its range unique ids for those would be 6 and 7 (for second row in Work Schedule). If any other mutually exclusive schedule is present , ID creation would start from 1 again (work schedule row3 type month end ) ID 1 to 5 again in this case.. If same also covers any other date range of schedule, the IDs would be incremental 6 and 7 for last row. The final output would be like this dataframe:
ID TYPE startdate enddate
1 1 REGULAR 1/1/2014 3/15/2014
2 2 REGULAR 1/1/2014 3/15/2014
3 3 REGULAR 1/1/2014 3/15/2014
4 4 REGULAR 1/1/2014 3/15/2014
5 5 REGULAR 1/1/2014 3/15/2014
6 6 OVERTIME 1/7/2014 1/10/2014
7 7 OVERTIME 1/7/2014 1/10/2014
8 1 MONTHEND 3/16/2014 3/22/2014
9 2 MONTHEND 3/16/2014 3/22/2014
10 3 MONTHEND 3/16/2014 3/22/2014
11 4 MONTHEND 3/16/2014 3/22/2014
12 5 MONTHEND 3/16/2014 3/22/2014
13 6 OVERTIME 3/30/2014 3/31/2014
14 7 OVERTIME 3/30/2014 3/31/2014