I have the below data frame:
df = pd.DataFrame([['A',1,2],['B',1,5],['A',2,5],['C',1,8],['A',1,5]], columns = ['person','status','result'])
  person  status  result
0      A       1       2
1      B       1       5
2      A       2       5
3      C       1       8
4      A       1       5
My aim: I need to make person and status as index and check the result of each index. However, if there is index duplicate, I want to keep it such that person A with status 1 has 2 results 2 and 5
status    1    2
person          
A       2.0  5.0
A       5.0
B       5.0  NaN
C       8.0  NaN
My attempt:
df1.set_index(['person','status'])['result'].unstack()
But this does not work as duplicate of index is not allowed.
 
    