Created
May 25, 2022 05:33
-
-
Save kvnkho/84e3cb5274e018a51ebf8e4790c88bc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # case 1: more shuffle | |
| df.sort_values(["c","d"]).drop_duplicates(subset=["d"], keep="last") | |
| # case 2: less shuffle | |
| idx = df.groupby("d")["c"].idxmax() | |
| df.merge(idx, left_index=True, right_on="c") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment