【问题标题】:AttributeError: module 'pandas' has no attribute 'drop_duplicates'AttributeError:模块“pandas”没有属性“drop_duplicates”
【发布时间】:2021-09-04 14:30:01
【问题描述】:

错误:“AttributeError:模块'pandas'没有属性'drop_duplicates'” 这是一段一直运行良好的代码的新错误,有问题的代码:

def The_function():
   file = os.getcwd() + "the_file.xls"
   xls = pd.ExcelFile(file)
   the_sheets = []
   for sheet in xls.sheet_names:
      the_sheets.append(xls.parse(sheet))
   result = pd.concat(the_sheets)
   result = pd.drop_duplicates(subset='Trade ID', keep="first")
   return results

有人对可能发生的事情有任何想法吗?非常感谢任何帮助!

谢谢

【问题讨论】:

  • 我觉得应该是result.drop_duplicates...

标签: python pandas drop-duplicates


【解决方案1】:

开关:

result = pd.drop_duplicates(subset='Trade ID', keep="first")

作者:

result = result.drop_duplicates(subset='Trade ID', keep="first")

【讨论】:

    猜你喜欢
    • 2016-11-28
    • 2019-05-23
    • 2018-09-18
    • 1970-01-01
    • 2017-09-27
    • 2020-11-22
    • 2021-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多