簡體   English   中英

如何使用Pandas格式化數據(格式化情感分析結果的數據格式)

[英]how to format data using Pandas (format the data format of the results of sentiment analysis)

我正在使用 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}]

輸出結果以列表格式輸出。

因此,我想將其轉換為如下所示的數據幀格式。 我應該做什么樣的處理?

在此處輸入圖片說明

嘗試這個:

sentiment = pipe (["This restaurant is awesome", "This restaurant is aweful"])
df = pd.DataFrame(sentiment)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM