I tried to extract birthyear and deathyear from a short text looking like that in a column in a Pandas DataFrame :
firstname lastname (1937-2015)
I used this code to get the first year:
data = re.findall(r'\d+', txt)
if len(data) > 0 :
data = float(data[0])
if data >= 1800 and data <= 2021 :
return data
return None
but I can't extract the second year from the text.
When I change data[0] into data[1] for example, I have an error message "list index out of range"