I currently have a DataFrame that looks like this
user | preference
----------------
Alex | tea
Alex | cookie
Alex | apple
Peter | coffee
Peter | apple
Peter | banana
John | tea
I need to transform the above to a DF that will map a user to all the unique values of the preference column. If user has that preference, we will assign 1 if not 0. So, the result should look like this
user | preference | value
-------------------------
Alex | tea | 1
Alex | coffee | 0
Alex | cookie | 1
Alex | apple | 1
Alex | banana | 0
Peter | tea | 0
Peter | coffee | 1
Peter | cookie | 0
Peter | apple | 1
Peter | banana | 1
John | tea | 1
John | coffee | 0
John | cookie | 0
John | apple | 0
John | banana | 0