I have a python list made up of usernames and time stamp tuples. Imagine it's like the following:
[(username,datetime_obj),(username,datetime_obj),(username,datetime_obj),(username,datetime_obj),(username,datetime_obj),(username,datetime_obj),(username,datetime_obj),(username,datetime_obj),(username,datetime_obj)]
Next, imagine the list above has only 3 unique usernames, but that all datetime objects are unique.
What's the most efficient, pythonic way to derive a new list from the one above, which is again made up of tuples and the same usernames, except that next to each username, the most recent datetime_obj in the list (for that particular username) is repeatedly attached.
E.g. if starting list was [(sam,1),(sam,7),(sam,8),(jon,4),(mel,9),(mel,2),(mel,10),(jon,3),(jon,6)], I end up with [(sam,1),(sam,1),(sam,1),(jon,3),(mel,2),(mel,2),(mel,2),(jon,3),(jon,3)].
I used ints to depict datetime objects in the example above. This was just for simplicity.
Thanks in advance.