Goal: replace values in column que_text with matches of re.search pattern. Else None
Problem: Receiving only None values in que_text_new column although regex pattern is thoroughly tested!
def override(s):
x = re.search(r'(an|frage(\s+ich)?)\s+d(i|ı)e\s+Staatsreg(i|ı)erung(.*)(Dresden(\.|,|\s+)?)?', str(s), flags = re.DOTALL | re.MULTILINE))
if x :
return x.group(5)
return None
df2['que_text_new'] = df2['que_text'].apply(override)
What am i doing wrong? removing return None doesent help. There must be some structural error within my function, i assume.
sused theoverridefunction?sis supposed to be an arbitrary placeholder just like in loops?!re.searchmethod. Before editing the question, you hadstr(s)(that is why I mention it in my answer).