0

I have a data frame (df) like this:

sem|course|count
sem1|A|1
sem1|B|2
sem1|C|1
sem2|A|2
sem2|B|2
sem2|C|2
sem3|C|2
sem4|A|2

From the above data frame,I want output as a dataframe like this:

  sem1|sem2|sem3|sem4
A  1|2|0|2
B  2|2|0|0
C  1|2|2|0

I have tried the following code:

df.groupby(["sem","course"]).apply(list)

I haven't got the expected output.Could anyone help?

Sri Test
  • 389
  • 1
  • 4
  • 21

0 Answers0