Reverse a get_dummies encoding in pandas November 21, 2023 by Tarik Pretty one-liner 🙂 new_df = df.idxmax(axis=1)