Given a dataframe, how would you identify and remove duplicates based on multiple conditional rules and move them to a separate dataframe?
Represent the dataframe as a list of dictionaries and return (retained, duplicates), preserving input order within both outputs. For rows with mode="exact", duplicates share entity_id, day, and value; for rows with mode="grouped", duplicates share only entity_id and day. Keep the first row for each conditional key and move later matches to the duplicate output.
def separate_duplicates(rows):