1

I have a dataframe with 1.5M rows and one column. It looks like:

enter image description here

I want to split the column 'jobroles' into multiple columns with 1s and 0s (hot-coding). Following is what I have tried so far:

df_bits = df['jobroles'].str.join(sep=',').str.get_dummies(sep=',')

But it is not just splitting on "," but each and every digit. For example, "2424638" gets split into "2", "3", "4", "6" and "8". Below the result I am getting.

enter image description here

0

1 Answer 1

1

It should be just this:

df['jobroles'].str.get_dummies(',')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.