0

This is my dataset:

Name Assignment Scores
Boo Test1 0.9
Buzz Test3 0.7
Bree Test2 1.0
Boo Quiz 1.0
Buzz Test1 0.8

How I want my result:

Name Test1 Test3 Test2 Quiz
Boo 0.9 0 0 1.0
Buzz 0.8 0.7 0 0
Bree 0 0 1.0 0

.T only seems to work for the entire df and I tried .pivot() as well :/ Any help would be appreciated!

1 Answers1

1

use pivot_table

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.pivot_table.html

df.pivot_table('Scores', index='Name', columns='Assignment', fill_value=0)
Panda Kim
  • 6,246
  • 2
  • 12