0

I have a column in my dataframe called "Topic_Categories" whose entries are list of strings. For example:

enter image description here

I want to create a column for each of the distinct categories and enter 1 if category exists in the list and 0 if it does not. I have the list of categories as:

enter image description here

len(all_topic_categories gives 36. So I need 36 more columns.

Update- I was able to create new columns and filled them with 0 using

for col in all_topic_categories:
    dft[col] = 0

Sorry about the pictures, I don't know how to post cell output and input here

AmanArora
  • 2,187
  • 6
  • 17
  • 21

0 Answers0