NumPy reshape() - Convert 1D array to 2D array

You can create a 2D array from 1D array in Python NumPy.

import numpy

a = numpy.array([1, 2, 3, 4, 5, 6])
b = a.reshape(2, 3)

print(b)
# [[1 2 3]
#  [4 5 6]]

ndarray.flatten() and reshape()

import numpy

a = numpy.array([1, 2, 3, 4, 5, 6])
b = a.reshape(2, 3)

print(b)
# [[1 2 3]
#  [4 5 6]]

c = numpy.ndarray.flatten(b)
print(c)
# [1 2 3 4 5 6]

NumPy Array

NumPy Tutorial