I have a dataframe df that looks like
Date Type
2010 A
1998 A
2003 B
2003 C
2007 D
2010 D
2015 B
2015 B
2006 C
2006 C
1998 D
I need to transform it and count the occurence of each Type for each year. So my expected output is:
1998 2003 2006 2007 2010 2015
A 1 0 0 0 1 0
B 0 1 0 0 0 2
C 0 1 2 0 0 0
D 1 0 0 1 1 0
As i understood, i need to usepivot
here, right?
Something like df.pivot(index='Type', columns='Data', values=???)