Skip to content
Advertisement

How to split data in a column into some separate columns in Python?

So, I have a data frame given below:

JavaScript

I want to have the results in the og dataframe with some single line strings separately, such as [107.625764, -6.910353], [107.625871, -6.910358], split to 107.625764, -6.910353 . The detail of expected results are in the picture below. Expected Results

All I know that we can apply str.split method with specifying any specific delimiter. The method as follows:

JavaScript

Problem: I don’t know the proper delimiter that I should put after str.split(” “).

How to manipulate the value in a column of dataframe until I get my expected table, such as in the picture below? Expected Results

Advertisement

Answer

I have a solution with pure python.
first the geometry is a JSON like string,but it has syntax error which the key is single quote,JSON need double quotes,so I parse it by yaml.
Then I just need to format it to list data

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