I am trying to pivot a dataframe in Python for a school project. I know how to transform the rows into column, but what I don't know is how to populate that new columns with the value 1 or 0 depending the case. For example, now I have something like this:
Code Product
1 Water
1 Coke
2 Wine
3 Apples
and I want to turn it into something like this:
Code Water Coke Wine Apples
1 1 1 0 0
2 0 0 1 0
3 0 0 0 1
I searched the web and I could't find anything. Also, I'm not that advanced in Python language.
Thanks