본문 바로가기

PYTHON LANGUAGE

2D Array

1. Flatten 2D Array 

flatten_1 = list(itertools.chain.from_iterable(ARR)) #방법 1
flatten_2 = list(itertools.chain(*ARR))
flatten_3 = sum(ARR,[])
flatten_4 = [elem for temp_arr in ARR for elem in temp_arr]
FLAT = [j for temp in GRAPH for j in temp]

 

'PYTHON LANGUAGE' 카테고리의 다른 글

ZIP (aggregate two iterators as list of tuples)  (0) 2022.06.20
ITERTOOLS  (0) 2022.06.20
Sort  (0) 2022.06.19
DICTIONARY  (0) 2021.12.15