I have a dataset that represents patients visits to various doctors in a certain practice throughout a year.
Example-
doctor patient_no datetime
dr.kahn 1561 1/21/19 10:30:00
dr.gould 1397 2/06/19 12:30:00
dr.amoor 1596 2/11/19 9:00:00
dr.gould 995 10/07/19 12:30:00
dr.kahn 1561 10/14/19 9:30
I'm trying to create a new dataframe where each row is a unique doctor-patient pairing and shows the numbers of times that patient visited that doctor, along with the average time surpassed between visits for that particular patient-doctor pairing. So for instance if patient A went to dr.kahn 4 times in a year, what was the average amount of time in between patient A's consecutive appointments to dr.kahn.
Example-
doctor patient_no number_of_visits avg_time_passed_between_appointments
dr.gould 1054 7 2 months 1 days 2:00:00
dr.gould 1099 2 5 months 10 days 00:00:00
dr.kahn 875 12 0 months 26 days 0:30:00
Any help would be appreciated. Thanks!