I have a pandas dataframe that looks like this:
ImageID | labels | caption_text |
---|---|---|
0.JPG | 1 | Woman in swim suit holding parasol |
1.JPEG | 1 19 | a black and silver clock tower |
2.JPEG | 8 3 13 | This photo shows people skiing in the mountains. |
The labels for this data set range from 1 to 19 and I am trying to allocate them to their own column. The final dataframe will have an additional 19 columns with a 1 or 0.
For example, "8 3 13" will have a 1 in columns 8, 3 and 13 and 0's everywhere else.
So far I have managed to put them into arrays and managed to put them into columns, but neither of these gives me what I need.
Any ideas on how I can achieve this?
Thanks!