Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37856
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: numpy array operation |
| Date | 2013-01-29 10:28 +0100 |
| Organization | None |
| References | <f94d7654-2b87-404b-a0b0-76f1ccf8ee6c@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1167.1359451658.2939.python-list@python.org> (permalink) |
C. Ng wrote:
> Is there a numpy operation that does the following to the array?
>
> 1 2 ==> 4 3
> 3 4 2 1
How about
>>> a
array([[1, 2],
[3, 4]])
>>> a[::-1].transpose()[::-1].transpose()
array([[4, 3],
[2, 1]])
Or did you mean
>>> a.reshape((4,))[::-1].reshape((2,2))
array([[4, 3],
[2, 1]])
Or even
>>> -a + 5
array([[4, 3],
[2, 1]])
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
numpy array operation "C. Ng" <ngcbmy@gmail.com> - 2013-01-29 00:41 -0800
Re: numpy array operation Peter Otten <__peter__@web.de> - 2013-01-29 10:28 +0100
Re: numpy array operation Tim Williams <tjandacw@cox.net> - 2013-01-29 04:59 -0800
Re: numpy array operation Alok Singhal <as8ca@virginia.edu> - 2013-01-29 18:49 +0000
Re: numpy array operation Terry Reedy <tjreedy@udel.edu> - 2013-01-29 15:05 -0500
csiph-web