I have a dataframe like this: df = pd.DataFrame({'id':{1,2,3,4,4}, 'course':{'english', 'art', 'math', 'english', 'chem'}, 'result':{'a','b','c','a','b'}}) I want to pivot this such that: course English art math sci chem id 1 a - - - - 2 - b - - - 3 - - c - - 4 a - - - b Note: There are repeated values in ID, results & Courses. Due to the duplicate values, I am not able to pivot it. Continue reading...