Skip to content
Advertisement

Pandas Column Split but ignore splitting on specific pattern

I have a Pandas Series containing Several strings Patterns as below:

JavaScript

I would like to split and explode it such that the result would be as follows:

JavaScript

In order to do the explode I need to first split. However, if I use split(',') that also splits the items between [] which I do not want. I have tried using split using regex but was not able to find the correct pattern.

I would appreciate the support.

Advertisement

Answer

You can use a regex with a negative lookahead:

JavaScript

output:

JavaScript

regex demo

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