I am trying to extract names from Twitter text with the help of regex. But, despite the pattern the value returned is none, which not exactly the case. Where my code has wrong, I have no idea. I am using jupyter lab.
Sample text is pd.Series full_text
0 RT @SeamusHughes: The Taliban Stamp of approva...
1 RT @WFaqiri: Taliban and Afghan groups find co...
2 RT @DavidCornDC: Imagine what Fox News would h...
3 RT @DavidCornDC: Imagine what Fox News would h...
4 RT @billroggio: Even if you are inclined to tr...
5 RT @billroggio: I am sure we will hear the arg...
6 RT @KFILE: This did happen and it went exactly...
Name: full_text, dtype: object
My function defined is as follows:
def extract_user(text):
m = re.search(r"RT\s@\w+:", text)
return m
And, I apply the above function as below:
full_text.apply(extract_user)
But the values that I get in return are as follows:
0 None
1 None
2 None
3 None
4 None
...
21299 None
21300 None
21301 None
21302 None
21303 None
Name: full_text, Length: 21304, dtype: object