I've got two data frames - Employee punch data and employee names data:
DF1
punch_out punch_in date employee_number
1 16:00:00 06:00:00 2018-01-01 00000001
2 15:00:00 08:00:00 2018-08-01 00000001
DF2
employee_numb job_title start_date end_date
00000001 worker 2017-08-05 2018-07-01
00000001 manager 2018-07-01 3000-01-01
I need to join them so that in DF1 I would have a new column - "Job title" which will properly reflect the actual job title, according to the date.
My struggles are around the date conditions. So from the examples above: according to the example dates observation 1 should have job title "worker", but observation two has to have "manager".
If I do traditional join - it duplicates the records and I will have two rows for each DF1 row and employee 00000001 on 2018-01-01 will be both worker and manager.
The result should look like this
punch_out punch_in date employee_number Job Title
1 16:00:00 06:00:00 2018-01-01 00000001 worker
2 15:00:00 08:00:00 2018-08-01 00000001 manager