Issue
I have a df with only one column. The dtype is object
:
column_1
1,2,3
2,3,4
I want to extracted those comman separeted values to make new columns,like this:
column_1 column_2 column_3 column_4
1,2,0.3 1 2 0.3
2,3,0.4 2 3 0.4
I tried something with .split(',')
but it's failed.
What's the best way to do it?
Thanks
Solution
Try with split
out = df.join(pd.DataFrame(df.column_1.str.split(',').tolist(),index=df.index))
Out[275]:
column_1 0 1 2
0 1,2,3 1 2 3
1 2,3,4 2 3 4
Answered By - BENY
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.