How to use Regex (in Pandas) to find hyphenated words in strings, then select only hyphenated words with 2 characters?
This is the code I have so far to select the hyphenated words:
df_hyph = df[df["Sentence"].str.contains(r'\b(?:-)')]
Now I want to select the words with 2 or more characters:
df_2 = df_hyph[df_hyph["Sentence"].str.contains(r'a-z')]
This line isn't working, what am I doing wrong?
source https://stackoverflow.com/questions/71697993/how-to-use-regex-in-pandas-to-find-hyphenated-words-in-strings-then-select-on
Comments
Post a Comment