I want to drop rows in a pandas dataframe where value in one column A is duplicate and value in some other column B is not a duplicate given A. An illustrative example:
df = pd.DataFrame({'A': ['cat', 'dog', 'cat', 'cat', 'bat'],
'B': ['x', 'y', 'x', 'z', 'z'],
'C': [10, 20, 30, 40, 50]})
The desired output has Row 3 dropped as "cat" is duplicate and "z" is distinct in "cat" rows:
df.drop_duplicates('A')
removes Rows 2 and 3, and df.drop_duplicates(subset=['A', 'B'])
removes Row 2; neither is what I am looking for here [1].