【问题标题】:I can't delete duplicated rows in a list with python我无法使用 python 删除列表中的重复行
【发布时间】:2019-04-04 09:12:24
【问题描述】:

我无法使用 python 删除列表中的重复行,这是什么问题?我该如何解决这个问题?提前致谢。

【问题讨论】:

  • 使用np.unique()axis 参数。
  • 请始终将代码、数据和错误消息作为文本直接发布在 SO 上,而不是图片。

标签: python pandas numpy jupyter-notebook numpy-ndarray


【解决方案1】:

如果你想删除列表中的相同元素,你可以这样做:

for i in reversed(range(len(list))):
    if l[i] in l[0:i]:
        l.pop(i)

【讨论】:

    猜你喜欢
    • 2019-08-03
    • 1970-01-01
    • 2021-01-24
    • 2017-11-14
    • 2020-06-12
    • 2014-07-14
    • 2018-12-04
    • 1970-01-01
    • 2012-03-20
    相关资源
    最近更新 更多