我有兩個員工數據如下的數據框。一個數據文件包含員工數據,其中包括員工生病的日期,另一個數據文件具有員工工作日期(即以日期範圍表示)。 我想通過查看某個員工的「病假」落在「工作範圍」中的哪個位置來合併這兩個文件(希望在熊貓中)。例如,在下面的圖像/數據中,員工1在2015年11月25日,2015年12月23日和2015年12月10日生病。這些工作範圍分別在2015年11月21日 - 2015年11月29日,2015年12月21日 - 2015年12月29日和2015年10月9日 - 2015年10月17日。如何通過在一個數據幀中查看另一個數據幀中日期範圍內的日期來組合Pandas數據框?
員工工作日期的數據:
╔══════════╦════════════╦════════════╗
║ Employee ║ datein ║ dateout ║
╠══════════╬════════════╬════════════╣
║ 1 ║ 11/21/2015 ║ 11/29/2015 ║
║ 2 ║ 12/9/2015 ║ 12/14/2015 ║
║ 3 ║ 11/10/2015 ║ 11/19/2015 ║
║ 4 ║ 11/11/2015 ║ 11/17/2015 ║
║ 5 ║ 11/30/2015 ║ 12/8/2015 ║
║ 1 ║ 12/21/2015 ║ 12/29/2015 ║
║ 2 ║ 1/7/2016 ║ 1/12/2016 ║
║ 3 ║ 12/10/2015 ║ 12/19/2015 ║
║ 4 ║ 12/10/2015 ║ 12/16/2015 ║
║ 5 ║ 12/30/2015 ║ 1/7/2016 ║
║ 1 ║ 10/9/2015 ║ 10/17/2015 ║
║ 2 ║ 10/27/2015 ║ 11/1/2015 ║
║ 3 ║ 9/28/2015 ║ 10/7/2015 ║
║ 4 ║ 9/29/2015 ║ 10/5/2015 ║
╚══════════╩════════════╩════════════╝
員工SICK日期的數據:
╔══════════╦════════════╦═══════════╗
║ Employee ║ sickDate ║ sickness ║
╠══════════╬════════════╬═══════════╣
║ 1 ║ 11/25/2015 ║ flu ║
║ 10 ║ 11/21/2015 ║ hd ║
║ 21 ║ 9/20/2015 ║ other ║
║ 1 ║ 12/23/2015 ║ other ║
║ 4 ║ 12/13/2015 ║ vacationx ║
║ 7 ║ 7/21/2015 ║ cough ║
║ 3 ║ 10/1/2015 ║ rash ║
║ 4 ║ 10/5/2015 ║ other ║
║ 5 ║ 1/7/2016 ║ eyex ║
║ 2 ║ 12/12/2015 ║ tanx ║
║ 1 ║ 10/12/2015 ║ fatiguex ║
╚══════════╩════════════╩═══════════╝
統一數據:
╔══════════╦════════════╦════════════╦════════════╦═══════════╗
║ Employee ║ datein ║ dateout ║ sickDate ║ sickness ║
╠══════════╬════════════╬════════════╬════════════╬═══════════╣
║ 1 ║ 11/21/2015 ║ 11/29/2015 ║ 11/25/2015 ║ flu ║
║ 2 ║ 12/9/2015 ║ 12/14/2015 ║ 12/12/2015 ║ tanx ║
║ 3 ║ 11/10/2015 ║ 11/19/2015 ║ ║ ║
║ 4 ║ 11/11/2015 ║ 11/17/2015 ║ ║ ║
║ 5 ║ 11/30/2015 ║ 12/8/2015 ║ ║ ║
║ 1 ║ 12/21/2015 ║ 12/29/2015 ║ 12/23/2015 ║ other ║
║ 2 ║ 1/7/2016 ║ 1/12/2016 ║ ║ ║
║ 3 ║ 12/10/2015 ║ 12/19/2015 ║ ║ ║
║ 4 ║ 12/10/2015 ║ 12/16/2015 ║ 12/13/2015 ║ vacationx ║
║ 5 ║ 12/30/2015 ║ 1/7/2016 ║ 1/7/2016 ║ eyex ║
║ 1 ║ 10/9/2015 ║ 10/17/2015 ║ 10/12/2015 ║ fatiguex ║
║ 2 ║ 10/27/2015 ║ 11/1/2015 ║ ║ ║
║ 3 ║ 9/28/2015 ║ 10/7/2015 ║ 10/1/2015 ║ rash ║
║ 4 ║ 9/29/2015 ║ 10/5/2015 ║ 10/5/2015 ║ other ║
╚══════════╩════════════╩════════════╩════════════╩═══════════╝
我怎麼做,在大熊貓或Python? (謝謝你的幫助!)
對不起時,我把它應用到我的「做大」的數據文件,這是行不通的。我已將這些數據放在Google文檔中。 2個選項卡。 https://docs.google.com/spreadsheets/d/1Gyw2if41MU8wSbjto6rQfLW9x68_kqTOzsqcZ-laSqA/edit?usp=sharing – Codetradr