Đôi khi, trong khi làm việc với ma trận Python, chúng ta có thể gặp vấn đề trong đó chúng ta cần thực hiện nhóm của tất cả các yếu tố là giống nhau. Loại vấn đề này có thể có ứng dụng trong các miền dữ liệu. Hãy để thảo luận về những cách nhất định trong đó nhiệm vụ này có thể được thực hiện.
Đầu vào: test_list = [1, 3, 4, 4, 2, 3] đầu ra: [[1], [2], [3, 3], [4, 4]]]] : test_list = [1, 3, 4, 4, 2, 3]
Output : [[1], [2], [3, 3], [4, 4]]Đầu vào: test_list = [1, 3, 4, 2] đầu ra: [[1], [2], [3], [4]] : test_list = [1, 3, 4, 2]
Output : [[1], [2], [3], [4]]
Phương pháp số 1: Sử dụng danh sách hiểu + groupby[]
Sự kết hợp của các hàm trên cung cấp giải pháp khả thi cho vấn đề này. Trong đó, chúng tôi thực hiện nhiệm vụ nhóm sử dụng groupby [] và danh sách hiểu biết hỗ trợ trong phép lặp.
The combination of above functions provide possible solution to this problem. In this, we perform task of grouping using groupby[] and list comprehension assists in iteration.
from
itertools
import
groupby
test_list
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]1
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]2
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]3
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]4
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]3
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]3
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]2
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}2
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}5
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]1
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}9
groupby[]
0groupby[]
1 groupby[]
2groupby[]
3The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
groupby[]
9 The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
from
2Đầu ra:
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]
Phương pháp số 2: Sử dụng danh sách hiểu + from
3 Đây là một cách tiếp cận khác cho vấn đề này. Trong đó, chúng tôi nhận được các giá trị cùng với tần số của nó bằng cách sử dụng bộ đếm [] và sau đó sử dụng danh sách hiểu để nhân từng phần tử với tần số
This is yet another approach to this problem. In this, we get the values along with it’s frequency using Counter[] and then employ list comprehension to multiply each element with frequency to get duplicates
from
from
5import
from
7
test_list
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]1
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]2
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]3
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]4
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]3
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]3
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]2
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}2
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}5
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]1
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}9
groupby[]
0groupby[]
1 groupby[]
2groupby[]
3The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
groupby[]
9 The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
from
2The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
groupby[]
9 The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
from
2Đầu ra:
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]
Phương thức #2: Sử dụng LOOP + DefaultDict []
Điều này tương tự như phương pháp trên. Sự khác biệt là lưới trống ban đầu được tạo bằng DefaultDict []. : test_list = [[5, 8], [2, 0], [5, 4], [2, 3], [2, 9]]
Output : {5: [8, 4], 2: [0, 3, 9]}
Explanation : 8 and 4 are mapped to 5 in Matrix, all others to 2.
from
from
5import
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]60 : test_list = [[2, 8], [2, 0], [2, 4], [2, 3], [2, 9]]
Output : {2: [8, 4, 0, 3, 9]}
Explanation : All mapped to 2.
test_list
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2]
Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]
0 The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2]
Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]
05The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2]
Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]
6The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2]
Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]
3The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2]
Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]
08__109__2222213The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2]
Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]
1222
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]92
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}9
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]94
Python3
test_list
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]05
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]3
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]08__109__2222213
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]1222
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}2
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}5
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]34
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]12
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]36__
groupby[]
1
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]38
groupby[]
3 The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]44
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]45
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]46
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]12
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]48
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]250150
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]53
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
from
2Đầu ra
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}
Phương thức #2: Sử dụng LOOP + DefaultDict []
Điều này tương tự như phương pháp trên. Sự khác biệt là lưới trống ban đầu được tạo bằng DefaultDict [].
Python3
from
from
5import
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]60
test_list
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]05
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]3
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]08__109__2222213
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]1222
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}2
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}5
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}6
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]0
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]92
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}9
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]94
groupby[]
1
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]38
groupby[]
3 The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]44
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]45
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]46
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]12
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]48
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]2
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]50
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}0
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
The original list : [1, 3, 5, 1, 3, 2, 5, 4, 2] Matrix after grouping : [[1, 1], [2, 2], [3, 3], [4], [5, 5]]53
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}3
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}4
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}1
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}11
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}12
Đầu ra
The original list : [[5, 8], [2, 0], [5, 4], [2, 3], [7, 9]] The Grouped Matrix : {5: [8, 4], 2: [0, 3], 7: [9]}