I want to extract year from my Data Frame column data3['CopyRight'].
CopyRight
2015 Sony Music Entertainment
2015 Ultra Records , LLC under exclusive license
2014 , 2015 Epic Records , a division of Sony Music Entertainment
Compilation ( P ) 2014 Epic Records , a division of Sony Music Entertainment
2014 , 2015 Epic Records , a division of Sony Music Entertainment
2014 , 2015 Epic Records , a division of Sony Music Entertainment
I am using the below code to extract the year :
data3['CopyRight_year'] = data3['CopyRight'].str.extract('([0-9]+)', expand=False).str.strip()
with my Code I am only getting the First occurrence of year.
CopyRight_year
2015
2015
2014
2014
2014
2014
I want to extract all the years mentioned in the column.
Expected Output
CopyRight_year
2015
2015
2014,2015
2014
2014,2015
2014,2015