Firstly, sorry for a complex question from a non-complex user. I'm a medical researcher trying to create a list of people who have had both a CT scan and X-ray within 3 months. I have two excel/csv documents:
(1) is all people who have had a CT scan and has four headings: Ref_CT, Date_CT, Patient ID_CT, Patient Name_CT;
(2) is all people who have had an X-ray and has four: XR Ref, Date, Patient ID, Patient ID.
In both of these excels, only the references are unique values, as most people have have 2+ studies, and multiple studies happen on the same date.
My goal is to print rows of: Patient ID; Patient Name; CT_Date; Xray_1_Date; Xray_2_Date;... Xray_10_Date (people have had up to 10 Xrays). Any advice on a technique to use, however general, would be fantastic.
Thank you so much
Dataframes (1) (Headings offset for ease of interpretation)
Ref_CT Date_CT Patient ID_C Patient Name_CT
0 1 9/8/2019 12345 PersonA, Felix (Mr)
1 2 9/6/2018 12346 PersonB, Anthony(Mr)
2 3 9/6/2017 12347 PersonC, Trev (Mrs)
3 4 9/6/2016 12348 PersonD, Jeremy (Mr)
4 5 9/8/2015 12348 PersonD, Jeremy (Mr)
(2)
X-Ray Ref Date Patient ID Patient Name
0 1 9/10/2019 12345 PersonA, Felix (Mr)
1 2 9/10/2018 12345 PersonA, Felix (Mr)
2 3 9/10/2017 12345 PersonA, Felix (Mr)
3 4 9/10/2016 12347 PersonC, Trev (Mrs)
4 5 9/10/2015 12348 PersonD, Jeremy (Mr)
Expected Output
Patient_ID CT_Date XR1_Date XR2_Date XR3_date
0 12345 9/8/2019 9/10/2019 9/6/2018 9/16/2017
1 12346 9/6/2019
2 12347 9/6/2017 9/10/2016
3 12348 9/6/2016 9/10/2015
4 12348 9/8/2015 9/10/2015
(Thank you @sammywemmy for providing advice on asking a better question)