我正在用BERT做情绪分析。我想把结果转换成DataFrame格式,但我不知道怎么做。如果有人知道,请让我知道。
相关网页如下https://huggingface.co/transformers/main_classes/pipelines.html
>>> pipe = pipeline ("text-classification")
>>> pipe (["This restaurant is awesome", "This restaurant is aweful"])
[{'label':'POSITIVE','score': 0.9998743534088135},
{'label':'NEGATIVE','score': 0.9996669292449951}]输出结果以列表格式输出。
因此,我想将其转换为如下所示的数据帧格式。我应该做什么样的处理?

发布于 2021-10-22 06:37:34
试试这个:
sentiment = pipe (["This restaurant is awesome", "This restaurant is aweful"])
df = pd.DataFrame(sentiment)https://stackoverflow.com/questions/69670480
复制相似问题