1import itertools
2
3a = [[1, 2], [3, 4], [5, 6]]
4list(itertools.chain.from_iterable(a))
5
6Output:- [1, 2, 3, 4, 5, 6]
1import numpy as np
2ini_array1 = np.array([[1, 2, 3], [2, 4, 5], [1, 2, 3]])
3result = ini_array1.flatten()
1# Create a 2D Numpy Array.
2arr = np. array([[0, 1, 2],
3[3, 4, 5],
4[6, 7, 8]])
5# convert 2D array to a 1D array of size 9.
6flat_arr = np. reshape(arr, 9)
7