Keep the newest record per email

Data framesMedium9 min

Your task

Given contacts with columns email and name, where later rows are more recent, keep only the LAST row for each email. Return email and name, sorted by email ascending.

Examples

latest_per_email(contacts: dataframe) -> dataframe
Example 1
Inputlatest_per_email(contacts)
contacts
emailname
a@x.comAnn
b@x.comBob
a@x.comAnn
c@x.comCy
b@x.comBobby
Output
emailname
a@x.comAnn
b@x.comBobby
c@x.comCy