我有一个如下所示的数据框。
data = {'Participant':['A', 'B', 'B', 'B', 'B', 'C', 'C', 'D', 'D', 'D'],
'Total test Result':[1, 4, 4, 4, 4, 2, 2, 3, 3, 3],
'result' : ['negative', 'negative', 'negative', 'negative', 'negative', 'negative', 'negative', 'negative', 'negative', 'negative', ],
'time': ['2021-06-14', '2021-06-21', '2021-06-24', '2021-06-28', '2021-07-01', '2021-07-05', '2021-07-08', '2021-06-17', '2021-06-17', '2021-06-20'] }
pres_df = pd.DataFrame(data)
pres_df
注意:如果有帮助,“时间”列采用日期时间格式。
我想创建一个新的数据框,其中“参与者”的多个值合并为 1 行,并创建多行时间和结果。所需的最终结果如下所示。