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

Sonu Mishra
  • 1,659
  • 4
  • 26
  • 45

1 Answers1

1

It should be just this:

df['jobroles'].str.get_dummies(',')
John Zwinck
  • 239,568
  • 38
  • 324
  • 436