我有以下数据框。我想要实现的是,对于每个“已完成日期”的工作,“时间已花费”列中的小时总和应等于7。例如,在6/10/2019,小时总和已为7,因此不需要进行调整。在2019年6月12日,小时总和为4.25,因此我需要插入带有“ Tab_description”“ Difference”的行,该行在“ Time_spent”下的差异为2.75。 6/13/2019和6/14/2019已经达到7,因此在那里无需执行任何操作。对于6/19/2019,我需要执行与6/12/2019相同的操作,插入总和为6的行,以使总和为7。
Date_worked Tab_description Time_spent
0 6/10/2019 Perform planning procedures 7.0
1 6/11/2019 Perform planning procedures 7.0
2 6/12/2019 Time off (away from the office) 2.25
3 6/12/2019 Staff meeting 1.0
4 6/12/2019 accounting & Risk Management Luncheon 1.0
5 6/13/2019 Perform planning procedures 7.0
6 6/14/2019 Time off (away from the office) 2.0
7 6/14/2019 Review policies and procedures 5.0
8 6/17/2019 Time off (away from the office) 7.0
9 6/18/2019 Perform planning procedures 7.0
10 6/19/2019 Staff meeting 1.0
11 6/20/2019 Time off (away from the office) 2.0
12 6/21/2019 Time off (away from the office) 1.0
13 6/24/2019 Staff meeting (FY 20 planning) 7.0
14 6/25/2019 FCR Kick-off meeting 1.0
15 6/26/2019 Time off (away from the office) 1.5
16 6/26/2019 Staff meeting 1.0
17 6/28/2019 Time off (away from the office) 1.0