Simple one but tired brain is letting me see the solution. I can not pivot because there are repeat values in 'number'. pd.DataFrame({'KeyID':[1,1,1,1,2,2,2,3,3,3], 'number':['a','a','c','d','a','b','c','a','b','c']}) I need each KeyID to have a 'd' if it does not then a row with NAN needs to be added. Both KeyId 2 and 3 are missing a 'd' so need a blank row adding. Continue reading...