Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77144

Re: [SciPy-User] Convert 3d NumPy array into 2d

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <maximilian.albert@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:: [': 0.04; "'a'": 0.09; 'subject:into': 0.09; 'url:github': 0.09; 'cc:addr:python- list': 0.11; 'array.': 0.16; 'numpy': 0.16; 'stuart': 0.16; 'subject:Convert': 0.16; 'subject:array': 0.16; 'obviously': 0.18; 'everyone,': 0.19; 'subject:] ': 0.20; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'cheers,': 0.24; '(see': 0.26; 'header:In-Reply- To:1': 0.27; '[1]': 0.29; 'array': 0.29; 'message- id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'dimensions': 0.31; 'cc:no real name:2**1': 0.33; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'useful': 0.36; 'url:org': 0.36; 'how': 0.40; 'url:reference': 0.84; 'url:v1': 0.84; 'sfxlen:1': 0.91; 'url:core': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=EJOfmFtMoKhjtKqtu5OIME3k9jhWMuenpygXkRK7o7M=; b=dR82PLbOaNo0wbboRkNC6f4EtTYQpresqDrYmaBcAfaswbzA6T9DwblxfIsU1G+9o2 ItnlJ6AHpbi1RCKBv8UgSH3s36mcN9dlY2PL24jfzGku6KuAFtC/FTxpDT6JRejTxTTg 0kr5k1SG4FRn3LZ3QWUzKIKbuDHJQlL9/wEjA8jbW+H1hA9kTOj5OeeUbdubEi4GsoXP XB76HMQp0iU7pKB0Z1+S/ztsNO/KCaRIqWq8XUtDNZN0ML64UkB6sC9CBkjKwTNMiaWm AQ2AsSbnSaeeKzI9Dx5J2buoyt8kdHmsIhPLp/Ty3WS5yY93ZKRZ9t6hld0Y06YP697B q/MQ==
MIME-Version 1.0
X-Received by 10.182.137.195 with SMTP id qk3mr30300928obb.5.1409156297721; Wed, 27 Aug 2014 09:18:17 -0700 (PDT)
In-Reply-To <CAEqOoUqDVpvP3KqvdC3Vu5HK=uB-uHpdycT4o9zfAbtzsGUM+A@mail.gmail.com>
References <CAEqOoUqDVpvP3KqvdC3Vu5HK=uB-uHpdycT4o9zfAbtzsGUM+A@mail.gmail.com>
Date Wed, 27 Aug 2014 17:18:17 +0100
Subject Re: [SciPy-User] Convert 3d NumPy array into 2d
From Maximilian Albert <maximilian.albert@gmail.com>
To SciPy Users List <scipy-user@scipy.org>
Content-Type multipart/alternative; boundary=001a11c361f68f121005019ec43f
Cc python-list@python.org, numpy-discussion@scipy.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13514.1409156305.18130.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1409156305 news.xs4all.nl 2932 [2001:888:2000:d::a6]:36644
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77144

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

[source]
<http://github.com/numpy/numpy/blob/v1.8.1/numpy/core/fromnumeric.py#L1072>
<http://docs.scipy.org/doc/numpy/reference/generated/numpy.squeeze.html#numpy.squeeze>
2014-08-27 16:08 GMT+01:00 phinn stuart <dphinnstuart@gmail.com>:

> Hi everyone, how can I convert (1L, 480L, 1440L) shaped numpy array into
> (480L, 1440L)?
>

If 'a' is your array then 'a.squeeze()' or 'a.squeeze(axis=0)' will do the
job (see the docs at [1]). You can also say a.reshape(480, 1440) but
obviously this is only useful if you know the exact dimensions of your
array.

Cheers,
Max

[1] http://docs.scipy.org/doc/numpy/reference/generated/numpy.squeeze.html

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [SciPy-User] Convert 3d NumPy array into 2d Maximilian Albert <maximilian.albert@gmail.com> - 2014-08-27 17:18 +0100

csiph-web