I have a pandas.Series of spacy.tokens.doc.Doc and I'm running this for loop:
for doc in docs:
print([(x.text, x.label_) for x in doc.ents])
But when I try to convert it into a list comprehension:
[(x.text, x.label) for x in doc.ents for doc in docs]
It throws this error:
name 'doc' is not defined
I understand the error but why does it say doc is undefined when I'm defining it in the list comprehension?