I have the following dataframe:
df =
id date_diag date_medication medication_code
1 01-01-2000 03-01-2000 A
2 01-01-2000 02-01-2000 A
3 01-01-2000 04-01-2000 B
4 01-01-2000 05-01-2000 B
I would like to create a table with the count of times a given medication was given after the date of the diagnoses:
df =
medication day1 day2 day3 day4 day5 day6 day7
A 0 1 1 0 0 0 0
B 0 0 0 1 1 0 0