how to extract int from column where numbers are presented in brackets

Viewed 22
bf['Films_Year']=bf['FILM'].apply(lambda var:var.split('(')[-1])

I get this output below

films(column name)

"
2015),
2015),
2015),
2015),
2015)
"

what should I do to get my year exactly?

1 Answers

You can use .str.extract() to get the integer part using a regular expression that matches the parenthesized year at the end.

bf['Films_Year']=bf['FILM'].str.extract(r'\((\d+)\)$')
Related