I am trying to do one-hot encoding for these clustered data frames. (grouped by length). Been trying to use sklearn's encoder but it seems to regard each individual row as one category instead of multiple.
Example input:
ID trace length
3 [A, B, C, C] 4
4 [A, B, C, C, D] 5
5 [A, B, C, C, D, E] 6
24 [A, B, C, C] 4
25 [A, B, C, C, D] 5
... ... ...
Expected output :
ID A B C D E length
3 1 1 1 0 0 4
4 1 1 1 1 0 5
5 1 1 1 1 1 6
24 1 1 1 0 0 4
25 1 1 1 1 0 5
.... ..... .. ......
tracea list or a string? Can you provide the input as DataFrame?