I have a dataframe
df:
cola colb colc cold
0 0 'a' 'b' 'c'
1 1 'd' None None
2 2 'g' 'h' None
I want to convert it into dict
where index are keys and list of column values are values like below:
d = {0 : [0,'a','b','c'], 1: [1,'d'], 2: [2,'g','h'] }
What I tried:
df.to_dict(orient='index')
I also tried with other values in orient
parameters but nothing worked.
EDIT:
I want to ignore the NULL values in dictionary like shown in output.