1·想把第二步的结果导入csv或者Excel都是这样的报错,应该怎么解决。
2·怎么样编码可以对一个文件夹里的txt文件重复上述步骤并导出结果
import pandas as pd
import cntext as ct
text = open('S2/1_Tom Coleman.txt', encoding='utf-8').read()
result_df=ct.sentiment(text=text,
diction=ct.load_pkl_dict('NRC.pkl')['NRC'],
lang='english')
result_df.to_csv("结果.csv",index=false)
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_5732\276906891.py in
7 diction=ct.load_pkl_dict('NRC.pkl')['NRC'],
8 lang='english')
----> 9 result_df.to_csv("结果.csv",index=false)
AttributeError: 'dict' object has no attribute 'to_csv'