I am currently have a table that I need to transform. The data set looks like this:
Period Course Teacher
0 1 Sci Teach1
1 2 Art Teach1
2 H Span Teach1
3 1 PE Teach2
4 2 CS Teach2
5 H Conf Teach2
6 1 AP Art Teach3
7 2 Dig Art Teach3
8 H Health Teach3
I would like it to look like the following:
Teacher H P1 P2
0 Teacher1 Span Sci Art
1 Teacher2 Conf PE CS
2 Teacher3 Health AP Art Dig Art
Not sure how to go about this, or if it is something pandas would handle.
I have tried df.transpose
which results in:
0 1 2 ... 6 7 8
Period 1 2 H ... 1 2 H
Course Sci Art Span ... AP Art Dig Art Health
Teacher Teach1 Teach1 Teach1 ... Teach3 Teach3 Teach3
I have tried using df.groupby(['Teacher'])
which returns an error grouper, exclusions, obj = get_grouper
I have searched for pivot
, melt
, transform
. Not sure of the language needed to search for examples of this type.