I would like to drop all values which are duplicates across a subset of two or more columns, without removing the entire row.
Dataframe:
A B C
0 foo g A
1 foo g G
2 yes y B
3 bar y B
Desired result:
A B C
0 foo g A
1 NaN NaN G
2 yes y B
3 bar Nan NaN
I have tried the drop_duplicates()
feature by grouping data into new data frames by columns and then re-appending them together, but this had its own issues.
I have also tried this solution and this one, but still am stuck. Any guidance would be much appreciated.
(updated original question)
source https://stackoverflow.com/questions/75751595/remove-duplicate-values-across-columns-in-pandas-dataframe-without-removing-ent
Comments
Post a Comment