【问题标题】:how can i get difference of two excel file in another file using python如何使用python在另一个文件中获取两个excel文件的差异
【发布时间】:2021-08-05 11:25:53
【问题描述】:

我有一个文件“product.xlsx”,它有 13 列和 2946 行。另一个文件“product_filter.xlsx”包括 13 列和 2609 行。

product_filter 具有相同的数据、相同的列标题和相同的行数据。只是缺少 333 行。 我只想要不同文件中的 340 行。例如,在 product_remaning.xlsx 中。

我对 python 知之甚少。所以,如果可能的话,写下你向对python一无所知的人解释的过程。

谢谢

【问题讨论】:

    标签: python excel dataframe data-analysis


    【解决方案1】:

    将 pandas 与 read_excel、contact 和 drop_duplicates 一起使用应该可以为您解决这个问题。这样的事情应该可以工作。

    import pandas as pd
    df1 = pd.read_excel(file_name1)
    df2 = pd.read_excel(file_name2)
    print(pd.concat([df1,df2]).drop_duplicates(keep=False))
    

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 2019-03-26
      • 2021-12-11
      • 1970-01-01
      • 2017-02-14
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 2019-01-28
      相关资源
      最近更新 更多