0

I have a dataframe of the form-

Id   Nums

1    0,1,0,0
2    0,0,0,1

I wish to split the column Nums in the form a feature vector for any Id --

Id   Num1   Num2   Num3   Num4

1    0       1       0     0
2    0       0       0     1

How can something of this sort can be done?

Rahul Dev
  • 602
  • 1
  • 6
  • 16
  • 1
    A simple [google search](https://www.google.com/search?q=Split%20a%20pandas%20dataframe%20column%20into%20multiple%20columns&cad=h) of your title would have yielded [multiple](https://stackoverflow.com/questions/23317342/pandas-dataframe-split-column-into-multiple-columns-right-align-inconsistent-c) [stack overflow](https://stackoverflow.com/questions/14745022/how-to-split-a-column-into-two-columns/14745484) pages that show how to do this. – pault Feb 15 '18 at 18:23
  • Is the `Nums` columns character or list? – Deena Feb 15 '18 at 18:23
  • 1
    @pault Entries (0,1,0,0) are seperated via comma & are not in the form of a list. – Rahul Dev Feb 15 '18 at 18:26
  • @pault do you want me reopen ? – BENY Feb 15 '18 at 18:29
  • @RahulDev ok so call str.split() first: like in [this post](https://stackoverflow.com/questions/14745022/how-to-split-a-column-into-two-columns/14745484) – pault Feb 15 '18 at 18:30
  • @Wen it's definitely a dupe, maybe I just picked the wrong dupe. – pault Feb 15 '18 at 18:30
  • 1
    @pault yep, I will modify the dup link – BENY Feb 15 '18 at 18:31

0 Answers0