I wish to transform column headers to values with their counts in Python (counts are the value numbers under each column header per unique date and id)
Data
id date dd aa
hey Q1 23 2 1
hey Q2 23 2 1
ok Q3 23 2 1
ok Q4 23 2 3
Desired
id date type
hey Q1 23 dd
hey Q1 23 dd
hey Q1 23 aa
hey Q2 23 dd
hey Q2 23 dd
hey Q2 23 aa
ok Q3 23 dd
ok Q3 23 dd
ok Q3 23 aa
ok Q4 23 dd
ok Q4 23 dd
ok Q4 23 aa
ok Q4 23 aa
ok Q4 23 aa
Doing
df.pivot(index="id", columns="Date", values=["dd"])
Any suggestion is appreciated