【问题标题】:I want to leave only one word with the same value in the DataFrame and delete the rest我想在 DataFrame 中只保留一个具有相同值的单词并删除其余单词
【发布时间】:2022-11-03 06:41:10
【问题描述】:

前任)

en ko
acrania a
acrania b
acrania c
acrania d

=>

en ko
acrania a

词对大约有40万对,很难一一提炼。请帮我。

【问题讨论】:

    标签: csv


    【解决方案1】:
    import pandas as pd
    data = {'en': ['acrania', 'acrania', 'acrania', 'acrania'], 'ko': ['a', 'b', 'c', "d"]}
    df = pd.DataFrame(data)
    df = df.drop_duplicates(subset='en', keep="first")
    print(df.to_string(index=False))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 2017-02-09
      • 2023-01-31
      • 2013-06-03
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多