# [Numpy-discussion] Convert 3d NumPy array into 2d

Benjamin Root ben.root at ou.edu
Wed Aug 27 11:15:54 EDT 2014

```There is also np.squeeze(), which will eliminate any singleton dimensions
(but I personally hate using it because it can accidentally squeeze out
dimensions that you didn't intend to squeeze when you have arbitrary input
data).

Ben Root

On Wed, Aug 27, 2014 at 11:12 AM, Wagner Sebastian <
Sebastian.Wagner.fl at ait.ac.at> wrote:

>  Hi,
>
>
>
> Our short example-data:
>
> >>> np.arange(10).reshape(1,5,2)
>
> array([[[0, 1],
>
>         [2, 3],
>
>         [4, 5],
>
>         [6, 7],
>
>         [8, 9]]])
>
> Shape is (1,5,2)
>
>
>
> Two possibilies:
>
> >>> data.reshape(5,2)
>
> array([[0, 1],
>
>        [2, 3],
>
>        [4, 5],
>
>        [6, 7],
>
>        [8, 9]])
>
>
>
> Or just:
>
> >>> data[0]
>
> array([[0, 1],
>
>        [2, 3],
>
>        [4, 5],
>
>        [6, 7],
>
>        [8, 9]])
>
>
>
>
>
> *From:* numpy-discussion-bounces at scipy.org [mailto:
> numpy-discussion-bounces at scipy.org] *On Behalf Of *phinn stuart
> *Sent:* Mittwoch, 27. August 2014 17:09
> *To:* python-list at python.org; scipy-user at scipy.org;
> numpy-discussion at scipy.org
> *Subject:* [Numpy-discussion] Convert 3d NumPy array into 2d
>
>
>
> Hi everyone, how can I convert (1L, 480L, 1440L) shaped numpy array into
> (480L, 1440L)?
>
>
>
> Thanks in the advance.
>
>
>
> phinn
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140827/069af658/attachment.html>
```

More information about the NumPy-Discussion mailing list