mardi 31 mars 2020

How to extract numbers from string using a pattern?

I have the following ten rows in a pandas dataframe. I want to extract the coordinates as in [49,49],[31,78] etc.(for each row).

I tried to use string extract but I couldn't figure out the pattern.

[{'y': 49, 'x': 49}, {'y': 78, 'x': 31}]
[{'y': 78, 'x': 31}, {'y': 75, 'x': 51}]
[{'y': 75, 'x': 51}, {'y': 71, 'x': 35}]
[{'y': 71, 'x': 35}, {'y': 95, 'x': 41}]
[{'y': 95, 'x': 41}, {'y': 88, 'x': 72}]
[{'y': 88, 'x': 72}, {'y': 75, 'x': 77}]
[{'y': 25, 'x': 23}, {'y': 15, 'x': 39}]
[{'y': 15, 'x': 39}, {'y': 20, 'x': 33}]
[{'y': 85, 'x': 61}, {'y': 80, 'x': 67}]
[{'y': 80, 'x': 67}, {'y': 61, 'x': 59}]
[{'y': 61, 'x': 59}, {'y': 45, 'x': 45}]

Aucun commentaire:

Enregistrer un commentaire