# Numpy ndarray.flatten() function | Python

• Last Updated : 22 Apr, 2020

`numpy.ndarray.flatten()` function return a copy of the array collapsed into one dimension.

Syntax : numpy.ndarray.flatten(order=’C’)

Parameters :
order : [{‘C’, ‘F’, ‘A’, ‘K’}, optional] ‘C’ means to flatten in row-major (C-style) order. ‘F’ means to flatten in column-major (Fortran- style) order. ‘A’ means to flatten in column-major order if a is Fortran contiguous in memory, row-major order otherwise. ‘K’ means to flatten a in the order the elements occur in memory. The default is ‘C’.

Return : [ndarray] A copy of the input array, flattened to one dimension.

Code #1 :

 `# Python program explaining``# numpy.ndarray.flatten() function`` ` `# importing numpy as geek ``import` `numpy as geek`` ` `arr ``=` `geek.array([[``5``, ``6``], [``7``, ``8``]])`` ` `gfg ``=` `arr.flatten()`` ` `print``( gfg )`

Output :

```[5 6 7 8]
```

Code #2 :

 `# Python program explaining``# numpy.ndarray.flatten() function`` ` `# importing numpy as geek ``import` `numpy as geek`` ` `arr ``=` `geek.array([[``5``, ``6``], [``7``, ``8``]])`` ` `gfg ``=` `arr.flatten(``'F'``)`` ` `print``( gfg )`

Output :

```[5 6 7 8]
```
My Personal Notes arrow_drop_up