I have a pandas DataFrame, with a column called positions
, that includes string values with the syntax of the following examples:
[{'y': 49, 'x': 44}, {'y': 78, 'x': 31}]
[{'y': 1, 'x': 63}, {'y': 0, 'x': 23}]
[{'y': 54, 'x': 9}, {'y': 78, 'x': 3}]
I want to create four new columns in my pandas DataFrame, y_start
, x_start
, y_end
, x_end
, that are extractions of only the numbers.
E.g. for the example of the first row, my new columns would have the following values:
y_start
= 49
x_start
= 44
y_end
= 78
x_end
= 31
To summarise, I am looking to extract just the first, second, third, and four occurrence of numbers and save these to individual columns.