Skip to content
Advertisement

Split column into multiple columns with unique values in pandas

I have the following dataframe:

JavaScript
JavaScript

which needs to be turned into:

JavaScript

Advertisement

Answer

Using pandas.concat:

JavaScript

For python < 3.8:

JavaScript

Output:

JavaScript

NB. add fillna('') to have empty strings for missing values

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement