I have a sample dataframe as given below.
import pandas as pd
data = {'ID':['001', '002', '003', '004', '005'],
'Aim2 Date':['9/3/19', '9/3/19', '9/13/19', '9/20/19', '9/23/19'],
'Aim2 C/I' :['Intervention', 'Intervention', 'Intervention', 'Control', 'Intervention'],
'Aim3 Date':['9/17/19','9/19/19','9/27/19','9/30/19','10/8/19'],
'Aim3 C/I' :['Control', 'Intervention', 'Control', 'Withdraw', 'Withdraw']}
df = pd.DataFrame(data)
The goal is to create a heatmap where the 2 columns of date are combined to form a single x-axis of heatmap in order. The y-axis of the heatmap has the ID
number. The heatmap should have 3 categories as given below:
- 0 - if there are no Interventions in both the C/I columns for that day.
- 1 - if there is 'Intervention' in
Aim2 C/I
column for that day. - 2 - if there is 'Intervention' in
Aim3 C/I
column for that day.
The image of the output as in how it should look is given below.
I am really struggling with checking the conditions, creating the categories and annotating them within the heatmap.