1

How can I change array:

np.array([[[a,b,c], [d,e,f]], [[g, h, i], [j, k, l]]])

to this format:

np.array([a,b,c,d,e,f,g,h,i,j,k,l])
Poia
  • 25
  • 7
  • 1
    What you want to do is better not called 'removing dimensions'; but 'flattening'. One could also 'remove dimensions' from arrays both technically, and, given, it were numbers, not letters, algebraically by certain kind of contraction, but that is not what you want. – decltype_auto Dec 10 '15 at 12:28

1 Answers1

1

I guess you want to use numpy.ndarray.flatten

There is also a parameter that determines whether to flatten in row-major or column-major order or preserve the ordering.

From the docs I linked:

>>> a = np.array([[1,2], [3,4]])
>>> a.flatten()
array([1, 2, 3, 4])
>>> a.flatten('F')
array([1, 3, 2, 4])
Konstantin Schubert
  • 3,242
  • 1
  • 31
  • 46