I have this data and want to get each key's max value. The key will be the first element (9,14,26).
(('14', '51600', 'Fashion Week'), 1)
(('9', '61577', 'Guiding Light'), 7)
(('9', '6856', 'Adlina Marie'), 22)
(('14', '120850', 'People Say (feat. Redman)'), 5)
(('26', '155571', "Thinking 'Bout You"), 30)
(('26', '156532', "Hello"), 8)
The final format will be:
(9, '6856', 'Adlina Marie', 22)
(14, '120850', 'People Say (feat. Redman)', 5)
(26, '155571', "Thinking 'Bout You", 30)
How to select the first column as the key and the last as the value to find the maximum of the value? I tried
groupbykey(lambda x:int(x[0][0])).mapValues(lambda x: max(x))
but it takes the second column as the value to find the max.