我有一个 CSV 文件,其中数据被组织成两列。
如何将负面情绪和正面情绪保存在单独的 csv 文件中。我的代码如下:
import pandas as pd df = pd.read_csv('~/Downloads/epinions3.csv') df_neg = df.loc[['Neg']] # get all negative sentiments and then save to a file df_pos = # get all positive sentiments and save to a file print(df_neg)
df.loc[df['class'] == 'Neg'].to_csv('negative.csv', index=False)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
点击生成二维码
我来说两句