0

I am trying to extract hashtags from the tweet column in dataframe. For that, I am using extractall with regex, but I am getting

ValueError: pattern contains no capture groups

Here is my code:

df['tweet.full_text'].str.extractall(r'#.*?(?=\s|$)')

1 Answers1

1

According to the docs, you need to specify a capture group (i.e., parentheses) for str.extract to, well, extract.

df['tweet.full_text'].str.extractall(r'(#[a-zA-Z0-9_]*)')

Regular Expression for alphanumeric and underscores

It work like this. enter image description here

Anytokin
  • 117
  • 5