I have seen this question in a few other posts but I can't seem to be applying it to my case.
I have a df that looks like this
A B C D E
--------------------------------------
Mark NY Confirmed Buy 10
Mark NY Confirmed Buy 22
Mark NY Confirmed Buy 40
John NY N/A Sell 55
John NY N/A Buy 30
Karl LA Confirmed Buy 22
Karl LA Confirmed Buy 66
Karl LA Confirmed Buy 25
and I would like to remove the duplicates wihtout loosing the rows to get something like
A B C D E
--------------------------------------
Mark NY Confirmed Buy 10
22
40
John NY N/A Sell 55
Buy 30
Karl LA Confirmed Buy 22
66
25
Any help?
1条答案
按热度按时间ruoxqz4g1#
我复制了
pandas.DataFrame
对象,如下所示:这给了我:
然后找到重复的值并将4列替换为
nan
。这给了我
为了使它与您想要的df完全一样,我用空字符串
""
替换了nan
值。df = df.fillna("")
这给了我