1

I'm looking for the max of item[6] in a list of list. Also I need the index of the list. 13 vs 23 = 23 and comparation[1] in this case. Any way to do that?

comparation = [
    [(Timestamp('2018-02-08 00:00:00'), 26, 211.8711395263672), (Timestamp('2018-02-21 00:00:00'), 34, 222.0032501220703), 1.2665138244628906, 178.94178009033203, 'MIN', (39, Timestamp('2018-02-28 00:00:00')), 13, 398],
    [(Timestamp('2018-02-08 00:00:00'), 26, 211.8711395263672), (Timestamp('2018-03-02 00:00:00'), 41, 220.2726287841797), 0.5600992838541666, 197.30855814615884, 'MIN', (49, Timestamp('2018-03-14 00:00:00')), 23, 388]
]

b = [max(p) for p in comparation]
Selcuk
  • 57,004
  • 12
  • 102
  • 110
Martin Bouhier
  • 173
  • 1
  • 10

1 Answers1

3

max function has a key argument you can use for this purpose:

max(comparation, key=lambda x: x[6])
Selcuk
  • 57,004
  • 12
  • 102
  • 110