Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Manolo =?iso-8859-1?Q?Mart=EDnez?= Newsgroups: comp.lang.python Subject: Re: numpy arrays Date: Wed, 23 Mar 2016 11:26:48 +0100 Lines: 27 Message-ID: References: <3774dc9b-f9d3-462b-bbe4-41b8b2244db7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.uni-berlin.de LrdpEYSRO8SYPlS0baRKNQWZJMIK2+9IYuWbwV1UyuHA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'arrays.': 0.16; 'numpy': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'element': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'arrays': 0.22; 'cc:no real name:2**0': 0.22; 'this:': 0.23; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'fastest': 0.27; 'this.': 0.28; 'array': 0.29; 'convert': 0.29; 'probably': 0.31; 'right?': 0.33; 'but': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'charset:us-ascii': 0.37; 'mean': 0.38; "didn't": 0.39; 'your': 0.60; 'received:82.223': 0.84 Content-Disposition: inline In-Reply-To: <3774dc9b-f9d3-462b-bbe4-41b8b2244db7@googlegroups.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Mailman-Approved-At: Wed, 23 Mar 2016 06:38:21 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105535 On 03/23/16 at 03:06am, Heli wrote: > I have a 2D numpy array like this: > > [[1,2,3,4], > [1,2,3,4], > [1,2,3,4] > [1,2,3,4]] > > Is there any fast way to convert this array to > > [[1,1,1,1], > [2,2,2,2] > [3,3,3,3] > [4,4,4,4]] You don't mean just transposing your original array, as in original_array.T, right? > In general I would need to retrieve every nth element of the interior > arrays in to single arrays. I know I can loop over and do this, but I > have really big arrays and I need the fastest way to do this. I didn't really get this, so transposing is probably not what you need. Anyway, just in case! Manolo