I have a list of 'words' I want to count below
word_list = ['one','three']
And I have a column within pandas dataframe with text below.
TEXT |
-------------------------------------------|
"Perhaps she'll be the one for me." |
"Is it two or one?" |
"Mayhaps it be three afterall..." |
"Three times and it's a charm." |
"One fish, two fish, red fish, blue fish." |
"There's only one cat in the hat." |
"One does not simply code into pandas." |
"Two nights later..." |
"Quoth the Raven... nevermore." |
The desired output is the following below, where it keeps the original text column, but only extracted the words in word_list to a new column
TEXT | EXTRACT
-------------------------------------------|---------------
"Perhaps she'll be the one for me." | one
"Is it two or one?" | one
"Mayhaps it be three afterall..." | three
"Three times and it's a charm." | three
"One fish, two fish, red fish, blue fish." | one
"There's only one cat in the hat." | one
"One does not simply code into pandas." | one
"Two nights later..." |
"Quoth the Raven... nevermore." |
Is there a way to do this in Python 2.7?