Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Simon Ward Newsgroups: comp.lang.python Subject: Re: numpy arrays Date: Wed, 23 Mar 2016 10:47:47 +0000 Lines: 25 Message-ID: References: <3774dc9b-f9d3-462b-bbe4-41b8b2244db7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de jBmQt3rUuU5+cdAOjSzqQwIxZWytEUbmlpNvbe4bzAkA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.135 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.75; '*S*': 0.02; 'method:': 0.09; '2016': 0.16; 'numpy': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'to:2**1': 0.21; 'this:': 0.23; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'array': 0.29; 'convert': 0.29; 'there': 0.36; 'url:org': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.40; 'received:uk': 0.61; 'url:0': 0.63; 'march': 0.64; 'mail.': 0.75; 'url:10': 0.79; 'url:scipy': 0.84; 'url:reference': 0.91 User-Agent: Kaiten Mail In-Reply-To: <3774dc9b-f9d3-462b-bbe4-41b8b2244db7@googlegroups.com> X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: -- X-Spam-Report: No, score=-2.9 required=5.0 tests=ALL_TRUSTED, BAYES_00 autolearn=ham version=3.3.2 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:105541 On 23 March 2016 10:06:56 GMT+00:00, Heli wrote: >Hi, > >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]] Use the transpose() method: http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.ndarray.transpose.html Simon -- Sent from Kaiten Mail. Please excuse my brevity.