I have a data frame where the values I want are in the same cell like this - words and all:
depth: 3230 m - 3750 m
I'm trying to write a regex to return the first number and then the second into a new data frame. so far, I can get the values with this:
top_depthdf=df[0].str.extract(r'depth:\s(\d+(?:\.\d+)?)', flags=re.I).astype(float)
base_depthdf=df[0].str.extract(r'-\s(\d+(?:\.\d+)?)', flags=re.I).astype(float)
where I am having an issue is that these patterns are not unique in this data, especially the base depth one. Other numbers have a similar pattern and my script is returning them instead of the base depth if they occur before the depth row. I was wondering if there is a way to write the base_depthdf in such a way that it looks for the 'depth:' part first and then looks for that pattern?