October 2019
Beginner to intermediate
674 pages
16h 43m
English
Ravel helps to flatten the data from multidimensional to 1D:
In [86]: ravel_array = np.arange(0,12).reshape(4, 3)In [87]: ravel_array.ravel()Out[87]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
The order in which the array is raveled can be set. The order can be "C", "F", "A", or "K". "C" is the default order, where the array gets flattened along the row major, while with "F", flattening occurs along the column major. "A" reads the array elements in a Fortran-like index-based order and "K" reads the elements in the order in which they are stored in memory:
In [88]: ravel_array.ravel(order = "F")Out[88]: array([ 0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11])
Read now
Unlock full access