Code Snippet: Year_Start_End = data_copy.Year_Start_End.unique()
Year_Start_End return a numpy.ndarray like this: "array(['2016_Jan_Jun', '2016_Jul_Dec', '2017_Jan_Jun', '2017_Jul_Dec', '2018_Jan_Jun', '2018_Jul_Dec'], dtype=object)"
I want to split each subtring in each element like this: 2016 and Jan_Jun which I will then pass as a parameter in the data_copy dataframe to get a subset of that.
I think your problem is to extract the actual string value from you raw string, so first you have to do it with regex (suppose your raw string exactly the same as in your question). And then since this you can then just do the basic string split-recombine method.
import re
a= "array(['2016_Jan_Jun', '2016_Jul_Dec', '2017_Jan_Jun', '2017_Jul_Dec', '2018_Jan_Jun', '2018_Jul_Dec'], dtype=object)"
string_list= re.findall(r"\d{4}_[A-Za-z_]{7}", a)
for i in range(len(string_list)):
temp= string_list[i].split('_')
string_list[i]= f'{temp[0]} and {string_list[i][len(temp[0])+1:]}'
print(string_list)
Correct me if im wrong or if i am miss-understanding your question :)