I have the following dataframe:
+------------+------------------+
| item | categories |
+------------+------------------+
| blue_shirt | ['red', 'white'] |
+------------+------------------+
| red_skirt | ['blue', 'red'] |
+------------+------------------+
and I want to get this instead:
+------------+-----+-------+------+
| item | red | white | blue |
+------------+-----+-------+------+
| blue_shirt | 1 | 1 | 0 |
+------------+-----+-------+------+
| red_skirt | 1 | 0 | 1 |
+------------+-----+-------+------+
here is what I tried:
orders = orders.join(pd.get_dummies(orders['Categories'].explode()))
it creates the right columns however it creates (a lot) of additional rows too. I want one row in the end for each item like in the example above.