Here is an example to reproduce my problem:
a = np.array([[1,2], [3,4], [6,7]])
b = np.array([[1,2], [3,4], [6,7,8]])
c = np.array([[1,2], [3,4], [6]])
print(a.flatten())
print(b.flatten())
print(c.flatten())
The problem exist when one of the arrays has an item less or more.
Output:
[1 2 3 4 6 7]
[list([1, 2]) list([3, 4]) list([6, 7, 8])] # Won't work
[list([1, 2]) list([3, 4]) list([6])] # Also won't work
How I want it:
[1 2 3 4 6 7]
[1 2 3 4 6 7 8]
[1 2 3 4 6]
Does anyone know how to flatten the list properly for example b and c?
flattenworks on 2d arrays; it changes the shape. Yourb(and 'c') is not 2d; it's 1d, already flat. You might need to step back and (re)readnumpydocumentation aboutshape(andflattenanddtype).