Skip to content Skip to sidebar Skip to footer

Pandas Extract Between Multiple Start Words And Multiple Stop Words

Following on from Pandas DataFrame extract between one START word and multiple STOP words, is it possible to extend the solution to multiple start words, too? Example shouldn't be

Solution 1:

You can use non-capturing groups to define the start/stop words alternatives:

df['COLUMN_NAME'].str.extract('(?:start_word1|start_word2)\s+(.*)\s+(?:end_word1|end_word2)')

Post a Comment for "Pandas Extract Between Multiple Start Words And Multiple Stop Words"