I have a dataframe which looks like this:
d = {'id': ['Mc','Web','G','M','F'], 'Person1':['x','x','x',None,None],'Person2':['x',None,'x','x',None], 'Person3':['x',None, None,None, None]}
df = pd.DataFrame(d)
df.set_index('id', inplace=True)
Person1 Person2 Person3
id
Mc x x x
Web x None None
G x x None
M None x None
F None None None
How can I get the id-value and column header if an id appears with more than one person?. For example, the above data frame should give the following dictionary:
{'Mc':[Person1, Person2, Person3], 'G':[Person1, Person2]}
Any help would be very much appreciated.