1

I have a dataframe:

 Values 1,2 nan,7,8 4 9,1 

How can I split this column so that each value is now in its own column?

 col1 col2 col3 1 2 nan 7 8 4 9 1 

The only answers I have found are about splitting a column into two columns. How to split a column into two columns?

2
  • df['Values'].str.split(',',expand=True) ? Commented Jan 22, 2020 at 9:12
  • If check more answers there is also solutions for multiple columns Commented Jan 22, 2020 at 9:13

1 Answer 1

1

Use str.split with expand=True:

print(df['Values'].str.split(',', expand=True)) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.