1In [12]: a = np.array([[1,2,3], [4,5,6]])
2
3In [13]: b = a.ravel()
4
5In [14]: b
6Out[14]: array([1, 2, 3, 4, 5, 6])
7
1# Python convert 2D into 1D array:
2
3import itertools
4x = [['foo'], ['bar', 'baz'], ['quux'], ("tup_1", "tup_2"), {1:"one", 2:"two"}]
5print list(itertools.chain(*x))
6print [element for sub in x for element in sub]
7
8# Output:
9
10['foo', 'bar', 'baz', 'quux', 'tup_1', 'tup_2', 1, 2]
11
12