'Pandas Split String in colum into colums with 0/1 ; get dummies on all characters of a string [duplicate]
Very likely this question was answered, but I can not find a good title. I have this pandas data structure, based on a given excel sheet:
| other columns | Code |
|---|---|
| ... | ABC |
| ... | CAB |
| ... | R |
I want to get this:
| other columns | A | B | C | R |
|---|---|---|---|---|
| ... | 1 | 1 | 1 | 0 |
| ... | 1 | 1 | 1 | 0 |
| ... | 0 | 0 | 0 | 1 |
Of course, I could iterate over each row and so this manually, but all ideas in my head will either be slow or memory consuming or both.
What is the one line solution here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
