drop_duplicates not working in pandas?(drop_duplicates 在 pandas 中不起作用?)
问题描述
我的代码的目的是导入 2 个 Excel 文件,比较它们,然后将差异打印到一个新的 Excel 文件中.
The purpose of my code is to import 2 Excel files, compare them, and print out the differences to a new Excel file.
但是,在连接所有数据并使用 drop_duplicates
函数后,代码会被控制台接受.但是,当打印到新的 excel 文件时,当天仍会保留重复项.
However, after concatenating all the data, and using the drop_duplicates
function, the code is accepted by the console. But, when printed to the new excel file, duplicates still remain within the day.
我错过了什么吗?drop_duplicates
函数是否无效?
Am I missing something? Is something nullifying the drop_duplicates
function?
我的代码如下:
推荐答案
你有 inplace=False
所以你没有修改 df
.你想要一个
You've got inplace=False
so you're not modifying df
. You want either
或
这篇关于drop_duplicates 在 pandas 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!