I want to calculate number of unique values of some parameter at certain time with two lists - one of values and one of timestamps (they contain millisecond info that is not really relevant and must be converted to seconds). Rn i have something like this
timestamps = ['00:22:33:645', '00:22:33:655', '00:22:34:645','00:22:34:745']
values = [1, 1, 2, 3]
grouped = groupby(zip(values, timestamps), lambda x: timestamp_to_seconds(x[1]))
but it results in
{1353:[(1, '00:22:33:645'), (1, '00:22:33:655')], 1354:[(2, '00:22:34:645'), (3, '00:22:34:745')]}
and i would prefer to keep only
{1353:[1, 1], 1354:[2, 3]}
so len(set(group))
would give accurate count. Is there a way to pass timestamps to key function without putting them in zip? Can lambda be skipped?
e: added actual example