【发布时间】:2019-05-27 20:36:08
【问题描述】:
我正在使用 csv 文件,我有很多行包含重复的单词,我想删除所有重复的单词(我也不想丢失句子的顺序)。
csv 文件示例(userID 和 description 是列名):
userID, description
12, hello world hello world
13, I will keep the 2000 followers same I will keep the 2000 followers same
14, I paid $2000 to the car I paid $2000 to the car I paid $2000 to the car
.
.
我希望输出为:
userID, description
12, hello world
13, I will keep the 2000 followers same
14, I paid $2000 to the car
.
.
我已经尝试过诸如123 之类的帖子,但它们都没有解决我的问题,也没有改变任何东西。 (我的输出文件的顺序很重要,因为我不想丢失订单)。如果你能提供一个代码示例,我可以在我身边运行并学习,那就太好了。 谢谢
[我用的是python 3.7版本]
【问题讨论】:
-
请格式化您的代码/数据。
-
@VictorHugoBorges 当然。谢谢。如果现在看起来还可以,请告诉我。
-
@RickyKim 我已经检查了那个帖子,但它没有回答我的问题。我已经包含在这篇文章中作为参考(#3)
-
@Bilgin 看到我的回答。它适用于您提供的 3 个示例
标签: python pandas csv dataframe