morgan freeman morgan freeman - 1 year ago 151
Python Question

Numpy array dimensions

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
(e.g.a is a 2 by 2 array)?

returns 4 and that doesn't help very much.

Answer Source

It is .shape:

Tuple of array dimensions.


>>> a.shape
(2, 2)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download