Skip to content
Advertisement

Splitting a Column using Pandas

I am trying to split the following column using Pandas: (df name is count)

JavaScript

to this desired outcome:

JavaScript

I have tried removing the word ‘POINT’, and both the brackets. But then I am met with an extra white space at the beginning of the column. I tried using:

JavaScript

But it was not removing the white space.

I was hoping to use this code to split the column:

JavaScript

Since the space between both x and y axis could be used as the separator, but the white space.

Advertisement

Answer

You can use .str.extract with regex pattern having capture groups:

JavaScript

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