df.head()
lang text
0 eng Johnnet went out on the field and felt under her feet..
1 eng John was shocked by this statement..
2 de Heute hat Marie köstlich gegessen und..
I have a dataframe with different languages that why i have a dictionary of two languages spacy :
eng_nlp= spacy.load('en_core_web_lg')
de_nlp= spacy.load('de_core_news_lg')
spacy_lang = {
'de': de_nlp,
'eng': eng_nlp
}
I wrote a function that looks displays only people in the column depending on the language.
def label_lang(lang,text):
model = spacy_lang[lang]
doc = model(text)
for ent in doc.ents:
if (ent.label_ == 'PERSON'):
return ent.text
NOW I WANT TO APPLY THIS TO THE COLUMN df['text'], BUT I GET AN ERROR
df.apply( lambda x: label_lang(spacy_lang[x],x['text']),axis = 1)
TypeError: unhashable type: 'Series'
I don't understand what I should use as an argument function (spacy_lang)