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]
1
  • BTW, it's spelled comparison. Commented Oct 31, 2019 at 1:14

1 Answer 1

3

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

max(comparation, key=lambda x: x[6])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.