numpy array operation

Alok Singhal as8ca at virginia.edu
Tue Jan 29 13:49:24 EST 2013


On Tue, 29 Jan 2013 00:41:54 -0800, C. Ng wrote:

> Is there a numpy operation that does the following to the array?
> 
> 1 2  ==>  4 3
> 3 4       2 1
> 
> Thanks in advance.

How about:

>>> import numpy as np
>>> a = np.array([[1,2],[3,4]])
>>> a
array([[1, 2],
       [3, 4]])
>>> a[::-1, ::-1]
array([[4, 3],
       [2, 1]])



More information about the Python-list mailing list