Question: Using python, how to filter and group sublist based on first entry of the sublist. For example, I have List1 (L1) which contains sublists that

Using python, how to filter and group sublist based on first entry of the sublist. For example, I have List1 (L1) which contains sublists that I want to group up together into a bigger sublist based on the first entry. In this case, all sublist starting with 0 are grouped together, as like L2. The desired list output is List 2 (L2).

L1 = [[0, 10.288], [0, 10.288], [1, 10.307], [1, 10.319], [2, 9.257], [2, 9.307], [2, 9.307]]

L2 = [[10.288, 10.288], [10.307, 10.319], [9.257, 9.307, 9.307]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!