I have a dataframe which occasionally has one or more observations for the same entity in a group. The groups are sorted by a rank and I only need the first entry/highest rank per entity per group. I have been removing them by concatenating the group_id and entity_id columns and keeping the first occurrence:
df = df.unique_stable(Some(&["group_entity_id".to_owned()]), UniqueKeepStrategy::First).unwrap();
This works but is slower than I would like. Is there a faster way to grab the first element of a group? Or a better way to formulate the problem?