My pandas dataframe (df):
Pattern Support
Bread 4
Milk 4
Bread,Milk 4
My code:
x = df.set_index('Pattern').to_dict()
print(x)
Output of my code:
{'Support':{'MILK': 4,'BREAD':4, 'BREAD,MILK':4}}
Expected Output:
{'MILK': 4,'BREAD':4, 'BREAD,MILK':4}
I do not want the name of the second column 'Support' to be the main key, just want to get the elements and the count as in the expected output. Is there any pythonic (python 3.5) way?