I have a pandas dataframe column that contains list of strings (lengths are different) like below:
df['category']
:
category | ...
---------
['Grocery & Gourmet Food', 'Cooking & Baking', 'Lard & Shortening', 'Shortening'] | ...
['Grocery & Gourmet Food', 'Candy & Chocolate', 'Mints'] | ...
['Grocery & Gourmet Food', 'Soups, Stocks & Broths', 'Broths', 'Chicken'] | ...
Now, I want to break this category column into different columns for each string element in the list. Is it possible to do using pandas? How I am gonna handle the column names?
I have gone through the answers of this question, but the difference is my list lengths are not the same always.
My expected output would be something like below:
category_1 | category_2 | category_n | other_columns
------------------------------------------------------------------
Grocery & Gourmet Food | Cooking & Baking | Lard & Shortening | ...
... | ... | ... | ...