I have a lambda function like this:
from Sastrawi.Stemmer.StemmerFactory import StemmerFactory
factory = StemmerFactory()
stemmer = factory.create_stemmer()
df['tweets_stemming'] = df['tweets_stopwords'].apply(lambda x: [stemmer.stem(stem) for stem in x])
And I want to convert this lambda function to function so I write this:
from Sastrawi.Stemmer.StemmerFactory import StemmerFactory
def stemmer_remover(stemming):
factory = StemmerFactory()
stemmer = factory.create_stemmer()
stemming = [stemmer.stem(stemming) for stemming in df['tweets_stopwords']]
return stemming
df['tweets_stemming'] = df['tweets_stopwords'].apply(stemmer_remover)
If using lambda function my code runs fine. But, if using function (not lambda) giving an error TypeError: descriptor 'lower' requires a 'str' object but received a 'list'. So, I think because my pandas dataframe from df['tweets_stopwords'] (see the image)
How to fix this?

.apply, how many times do you think the passed-in function gets called? What do you think gets passed to it? In your own words, in your version of the code using the function, how do you think the function is using the passed-in parameter?lambda <args>: <lambda body>can be simply replaced bydef some_name(<args>): return <lambda body>