Split dataframe based on duplicates available

5 views
Skip to first unread message

Момчил Божинов

unread,
Jul 16, 2026, 10:30:30 AM (2 days ago) Jul 16
to PyData
Hello,
First time caller

I have a question. Is it possible to split data frame based on duplicates availability
consider this:
duplicate_df = list_df[list_df.duplicated(subset=["Name"], keep="last")]
list_df = list_df.drop_duplicates(subset=["Name"], keep="last")

I have a list containing all the dups without the last one
the second list contains only the last one

how do I do this in 1 operation ?

Thanks
Momchil
Reply all
Reply to author
Forward
0 new messages