views:

74

answers:

1

Hello,

I'm currently trying to learn Numpy and Python. Given the following array:

import numpy as N
a = N.array([[1,2],[1,2]])

Is there a function that returns the dimensions of a (e.g.a is a 2 by 2 array).

size() returns 4 and that doesn't help very much.

Thanks.

+8  A: 

It is .shape:

ndarray.shape
Tuple of array dimensions.

Thus:

>>> a.shape
(2, 2)
Felix Kling