I have a dataframe that looks like this:
Sentence bin_class
"i wanna go to sleep. too late to take seroquel." 1
"Adam and Juliana are leaving me for 43 days take me with youuuu!" 0
And I also have a list of regex patterns I want to use on these sentences. What I want to do is re.search every pattern in my list on every every sentence in the dataframe and create a new column in the data frame that has a 1 if there is a matching regex and a zero otherwise. I have been able to run the regex patterns against the sentences in the dataframe to create a list of matches but am not sure how to create a new column on the data frame.
matches = []
for x in df['sentence']:
for i in regex:
match = re.search(i,x)
if match:
matches.append((x,i))