I have a pandas dataframe as follows:
A B C
1 2 x
1 2 y
3 4 z
3 5 x
I want that only 1 row remains of rows that share the same values in specific columns. In the example above I mean columns A and B. In other words, if the values of columns A and B occur more than once in the dataframe, only one row should remain (which one does not matter).
FWIW: the maximum number of so called duplicate rows (that is, where column A and B are the same) is 2.
The result should looke like this:
A B C
1 2 x
3 4 z
3 5 x
or
A B C
1 2 y
3 4 z
3 5 x
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…