我如何将 vader 情感脚本的输出转换为 csv 的数据框

How do i convert output from a vader sentiment script into a dataframe for a csv

我希望将我的输出转换为情绪分数的数据帧格式

我有一个输出数据框:

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
for transcript in transcript:
    vs = analyzer.polarity_scores(transcript)
    print("{:-<65} {}".format(transcript, str(vs)))


thank you for calling my name is Britney and her the pleasure speaking with %HESITATION yes this is clearer Craddock and I just want to let you know that %HESITATION my little pumpkin passed away oh oh okay let me %HESITATION get that set up here for you then okay can you just verify for me your mailing address eleven oh five west street was in California nine five six nine five  {'neg': 0.0, 'neu': 0.823, 'pos': 0.177, 'compound': 0.9001}
thank you %HESITATION and then %HESITATION you said pumpkin passed away if you don't mind me asking when did pumpkin patch %HESITATION in the last week and of last week okay so %HESITATION what we will do is we will cancel it effective  {'neg': 0.041, 'neu': 0.804, 'pos': 0.155, 'compound': 0.6705}
what is last week this ------------------------------------------ {'neg': 0.0, 'neu': 1.0, 'pos': 0.0, 'compound': 0.0}
so did you want to cancel it effective the tense so or the end of last week as in like it was Friday or Saturday %HESITATION %HESITATION %HESITATION %HESITATION the tent it was around the time okay so we will cancel it effective %HESITATION the ten just to you know make sure if there was any coverage dates if you have to submit anything we don't have to worry about that getting in the way and I do just have to read a quick verification to you okay okay so as you requested your plan for pumpkin will be canceled effective at five you worry tenth of two thousand twenty is the refund is due with the change it will be processed within seven business days and it also gives me a confirmation number did you want to write that down or just save it here on file  {'neg': 0.038, 'neu': 0.768, 'pos': 0.193, 'compound': 0.9676}
%HESITATION ----------------------------------------------------- {'neg': 0.0, 'neu': 1.0, 'pos': 0.0, 'compound': 0.0}
please leave it there on file all right and then did you have additional questions while I had you Clara  {'neg': 0.059, 'neu': 0.829, 'pos': 0.112, 'compound': 0.2732}
%HESITATION no no I don't I just want to let you people know that it is a pumpkin is gone and %HESITATION %HESITATION squeaker message %HESITATION %HESITATION I said if you have any anything you have questions about or you need to talk about something you feel free to call okay Clara okay okay good day okay thank you bye thank you bye bye  {'neg': 0.077, 'neu': 0.667, 'pos': 0.256, 'compound': 0.9038}

如您所见,所有输出都在一起。我希望此输出采用一种格式,其中显示句子,然后相关分数显示在列中 neg neutral positive 和 compound 就像数据框而不是 运行 句子。如何转换输出?

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
text = ['She is pretty', 'He is ugly']
 scores = []
for txt in text:
    vs = analyzer.polarity_scores(txt)
    scores.append(vs)
data = pd.DataFrame(text, columns= ['Text'])
data2 = pd.DataFrame(scores)
final_dataset= pd.concat([data,data2], axis=1)

希望这段代码对您有所帮助!