I have a data set where I need to group the duplicate records and then see if any of the group has been flagged; if so, I need to indicate that it has been flagged in a new column.
Sample input; the “Concat” column is where I’m looking for duplicates:
Customer_Reference Auth_ID Concat Flag
C001 A1234 AAA TRUE
C002 A758 AAA FALSE
C003 A6149 BBB FALSE
C004 A5271 CCC FALSE
C005 A0124 BBB FALSE
The behaviour I’m looking for is that “AAA” is a duplicate where at least one of them has the Flag of “TRUE”; therefore, it should be marked as “TRUE” in the (to be added) column.
I’ve been able to mark the duplicate records, and the groupby function seems to chunk it up correctly, but I can’t work out how to then apply an “If-Then” to each group to assign a value to the new column