我有在任何给定日期为给定问题ID所做的更改的数据库.CHANGED_PARAMETER中的值是对其进行更改的参数.
其已更改参数的旧值和新值分别在old_value new_value列中更新
Issue_Id | Due_Date | status | estimation_hour | changed_date | changed_parameter | old_value | new_value |
---|---|---|---|---|---|---|---|
101 | 1/31/2023 | closed | 40 | 1/10/2023 | status | Defined | Accepted |
101 | 1/31/2023 | closed | 40 | 1/15/2023 | estimation_hour | 0 | 20 |
101 | 1/31/2023 | closed | 40 | 1/16/2023 | estimation_hour | 20 | 30 |
101 | 1/31/2023 | closed | 40 | 1/16/2023 | Due_Date | 1/20/2023 | 1/31/2023 |
101 | 1/31/2023 | closed | 40 | 1/20/2023 | status | Accepted | InProgress |
101 | 1/31/2023 | closed | 40 | 1/25/2023 | estimation_hour | 30 | 40 |
101 | 1/31/2023 | closed | 40 | 1/30/2023 | status | InProgress | Closed |
102 | 2/28/2023 | closed | 50 | 1/10/2023 | status | Defined | Accepted |
102 | 2/28/2023 | closed | 50 | 1/15/2023 | estimation_hour | 0 | 30 |
102 | 2/28/2023 | closed | 50 | 1/20/2023 | status | Accepted | InProgress |
102 | 2/28/2023 | closed | 50 | 1/25/2023 | estimation_hour | 30 | 50 |
102 | 2/28/2023 | closed | 50 | 1/30/2023 | status | InProgress | Closed |
因此,现在我必须根据上述数据创建更改日期的问题ID的快照
所以我的最终表格应该是这样的
Issue_Id | Due_Date | status | estimation_hour | changed_date | changed_parameter | old_value | new_value |
---|---|---|---|---|---|---|---|
101 | 1/20/2023 | Accepted | 0 | 1/10/2023 | status | Defined | Accepted |
101 | 1/20/2023 | Accepted | 20 | 1/15/2023 | estimation_hour | 0 | 20 |
101 | 1/20/2023 | Accepted | 30 | 1/16/2023 | estimation_hour | 20 | 30 |
101 | 1/31/2023 | Accepted | 30 | 1/16/2023 | Due_Date | 1/20/2023 | 1/31/2023 |
101 | 1/31/2023 | InProgress | 30 | 1/20/2023 | status | Accepted | InProgress |
101 | 1/31/2023 | InProgress | 40 | 1/25/2023 | estimation_hour | 30 | 40 |
101 | 1/31/2023 | closed | 40 | 1/30/2023 | status | InProgress | Closed |
102 | 2/28/2023 | Accepted | 0 | 1/10/2023 | status | Defined | Accepted |
102 | 2/28/2023 | Accepted | 30 | 1/15/2023 | estimation_hour | 0 | 30 |
102 | 2/28/2023 | InProgress | 30 | 1/20/2023 | status | Accepted | InProgress |
102 | 2/28/2023 | InProgress | 50 | 1/25/2023 | estimation_hour | 30 | 50 |
102 | 2/28/2023 | closed | 50 | 1/30/2023 | status | InProgress | Closed |
我已经更新了Pandas DataFrame中的上述数据,并迭代了每一行.
在每次迭代中,我将更改参数的旧值更新为问题ID的先前可用行,直到相同.新值被更新到当前行,如下所示
迭代每一行都很耗时
第一次迭代
Issue_Id | Due_Date | status | estimation_hour | changed_date | changed_parameter | old_value | new_value |
---|---|---|---|---|---|---|---|
101 | 1/31/2023 | Accepted | 40 | 1/10/2023 | status | Defined | Accepted |
101 | 1/31/2023 | closed | 40 | 1/15/2023 | estimation_hour | 0 | 20 |
101 | 1/31/2023 | closed | 40 | 1/16/2023 | estimation_hour | 20 | 30 |
101 | 1/31/2023 | closed | 40 | 1/16/2023 | Due_Date | 1/20/2023 | 1/31/2023 |
101 | 1/31/2023 | closed | 40 | 1/20/2023 | status | Accepted | InProgress |
101 | 1/31/2023 | closed | 40 | 1/25/2023 | estimation_hour | 30 | 40 |
101 | 1/31/2023 | closed | 40 | 1/30/2023 | status | InProgress | Closed |
102 | 2/28/2023 | closed | 50 | 1/10/2023 | status | Defined | Accepted |
102 | 2/28/2023 | closed | 50 | 1/15/2023 | estimation_hour | 0 | 30 |
102 | 2/28/2023 | closed | 50 | 1/20/2023 | status | Accepted | InProgress |
102 | 2/28/2023 | closed | 50 | 1/25/2023 | estimation_hour | 30 | 50 |
102 | 2/28/2023 | closed | 50 | 1/30/2023 | status | InProgress | Closed |
第二次迭代
Issue_Id | Due_Date | status | estimation_hour | changed_date | changed_parameter | old_value | new_value |
---|---|---|---|---|---|---|---|
101 | 1/31/2023 | Accepted | 0 | 1/10/2023 | status | Defined | Accepted |
101 | 1/31/2023 | closed | 20 | 1/15/2023 | estimation_hour | 0 | 20 |
101 | 1/31/2023 | closed | 40 | 1/16/2023 | estimation_hour | 20 | 30 |
101 | 1/31/2023 | closed | 40 | 1/16/2023 | Due_Date | 1/20/2023 | 1/31/2023 |
101 | 1/31/2023 | closed | 40 | 1/20/2023 | status | Accepted | InProgress |
101 | 1/31/2023 | closed | 40 | 1/25/2023 | estimation_hour | 30 | 40 |
101 | 1/31/2023 | closed | 40 | 1/30/2023 | status | InProgress | Closed |
102 | 2/28/2023 | closed | 50 | 1/10/2023 | status | Defined | Accepted |
102 | 2/28/2023 | closed | 50 | 1/15/2023 | estimation_hour | 0 | 30 |
102 | 2/28/2023 | closed | 50 | 1/20/2023 | status | Accepted | InProgress |
102 | 2/28/2023 | closed | 50 | 1/25/2023 | estimation_hour | 30 | 50 |
102 | 2/28/2023 | closed | 50 | 1/30/2023 | status | InProgress | Closed |
第三次迭代
Issue_Id | Due_Date | status | estimation_hour | changed_date | changed_parameter | old_value | new_value |
---|---|---|---|---|---|---|---|
101 | 1/31/2023 | Accepted | 0 | 1/10/2023 | status | Defined | Accepted |
101 | 1/31/2023 | closed | 20 | 1/15/2023 | estimation_hour | 0 | 20 |
101 | 1/31/2023 | closed | 30 | 1/16/2023 | estimation_hour | 20 | 30 |
101 | 1/31/2023 | closed | 40 | 1/16/2023 | Due_Date | 1/20/2023 | 1/31/2023 |
101 | 1/31/2023 | closed | 40 | 1/20/2023 | status | Accepted | InProgress |
101 | 1/31/2023 | closed | 40 | 1/25/2023 | estimation_hour | 30 | 40 |
101 | 1/31/2023 | closed | 40 | 1/30/2023 | status | InProgress | Closed |
102 | 2/28/2023 | closed | 50 | 1/10/2023 | status | Defined | Accepted |
102 | 2/28/2023 | closed | 50 | 1/15/2023 | estimation_hour | 0 | 30 |
102 | 2/28/2023 | closed | 50 | 1/20/2023 | status | Accepted | InProgress |
102 | 2/28/2023 | closed | 50 | 1/25/2023 | estimation_hour | 30 | 50 |
102 | 2/28/2023 | closed | 50 | 1/30/2023 | status | InProgress | Closed |
第4次迭代
Issue_Id | Due_Date | status | estimation_hour | changed_date | changed_parameter | old_value | new_value |
---|---|---|---|---|---|---|---|
101 | 1/20/2023 | Accepted | 0 | 1/10/2023 | status | Defined | Accepted |
101 | 1/20/2023 | closed | 20 | 1/15/2023 | estimation_hour | 0 | 20 |
101 | 1/20/2023 | closed | 30 | 1/16/2023 | estimation_hour | 20 | 30 |
101 | 1/31/2023 | closed | 40 | 1/16/2023 | Due_Date | 1/20/2023 | 1/31/2023 |
101 | 1/31/2023 | closed | 40 | 1/20/2023 | status | Accepted | InProgress |
101 | 1/31/2023 | closed | 40 | 1/25/2023 | estimation_hour | 30 | 40 |
101 | 1/31/2023 | closed | 40 | 1/30/2023 | status | InProgress | Closed |
102 | 2/28/2023 | closed | 50 | 1/10/2023 | status | Defined | Accepted |
102 | 2/28/2023 | closed | 50 | 1/15/2023 | estimation_hour | 0 | 30 |
102 | 2/28/2023 | closed | 50 | 1/20/2023 | status | Accepted | InProgress |
102 | 2/28/2023 | closed | 50 | 1/25/2023 | estimation_hour | 30 | 50 |
102 | 2/28/2023 | closed | 50 | 1/30/2023 | status | InProgress | Closed |
第5次迭代
Issue_Id | Due_Date | status | estimation_hour | changed_date | changed_parameter | old_value | new_value |
---|---|---|---|---|---|---|---|
101 | 1/20/2023 | Accepted | 0 | 1/10/2023 | status | Defined | Accepted |
101 | 1/20/2023 | Accepted | 20 | 1/15/2023 | estimation_hour | 0 | 20 |
101 | 1/20/2023 | Accepted | 30 | 1/16/2023 | estimation_hour | 20 | 30 |
101 | 1/31/2023 | Accepted | 40 | 1/16/2023 | Due_Date | 1/20/2023 | 1/31/2023 |
101 | 1/31/2023 | InProgress | 40 | 1/20/2023 | status | Accepted | InProgress |
101 | 1/31/2023 | closed | 40 | 1/25/2023 | estimation_hour | 30 | 40 |
101 | 1/31/2023 | closed | 40 | 1/30/2023 | status | InProgress | Closed |
102 | 2/28/2023 | closed | 50 | 1/10/2023 | status | Defined | Accepted |
102 | 2/28/2023 | closed | 50 | 1/15/2023 | estimation_hour | 0 | 30 |
102 | 2/28/2023 | closed | 50 | 1/20/2023 | status | Accepted | InProgress |
102 | 2/28/2023 | closed | 50 | 1/25/2023 | estimation_hour | 30 | 50 |
102 | 2/28/2023 | closed | 50 | 1/30/2023 | status | InProgress | Closed |
以此类推..