'Visualization random sample with displaCy

How can I visualize using displaCy in a dataframe? I have a data called taks_output and want to visualize a sample of the columm msg_lower? What I did:

import pandas as pd
import numpy as np
import spacy 
import nltk
from spacy import displacy

df = task_output['msg_lower']
df = df.sample(n=1787)
displacy.render(df,  style='dep', jupyter=True, options={'distance': 90})

And I get

Invalid object passed to displaCy: Can only visualize Doc or Span objects, or dicts if set to manual=True.

What can I do?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source