0

Hey guys I have a quick question about dataframe stemming. You see I want to know how to iterate through a dataframe of text, stem each word, and then return the dataframe to the text is was originally in (With the stemmed word changes of course). I will give an example

dic = {0:['He was caught eating by the tree'],1:['She was playing with her friends']}
dic = pd.DataFrame(dic)
dic = dic.T
dic.rename(columns = {0:'text'},inplace=True)

When you run these 4 codes, you will get a dataframe of text. I would like to a method to iterate and stem each word as I have a dataframe constiting of over 30k of such sentences and would like to stem it. Thank you very much.

Josh Adams
  • 2,113
  • 2
  • 13
  • 25
Flaresun
  • 3
  • 1
  • Do you already have a stemming function and you only want to apply? Or do you need a stemming function? – moritz Dec 22 '21 at 15:17
  • [```this```](https://stackoverflow.com/questions/37443138/python-stemming-with-pandas-dataframe) answer that uses ```nltk``` is exactly what you need. I tried it on your data and it works. You can convert every row to a list, and apply the stemmer function to every word in your list. It might be a bit slow on 30k rows though – sophocles Dec 22 '21 at 15:24

0 Answers0