Skip to content
Advertisement

String column to multiple columns in DataFrame

I have a DataFrame with multiple columns:

JavaScript

Now I want to break column C(whose each entry is separated by n) into multiple column like this:

JavaScript

I tried few techniques but can’t make it. I tried to use df.apply but not able to fix NA columns. Is there a way to cleanly achieve this?

Thanks.

Advertisement

Answer

A solution using a regex with str.split:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement