0 votes
1 view
in Python by (47.8k points)

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

import numpy as np

a = np.array([[1,2],[1,2]])

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

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

1 Answer

0 votes
by (107k points)

To get Numpy array’s dimensions you can use shape() function. The output of the dimension will be in the form of the tuple:

An example that shows how to do it:-

import numpy as np

a = np.array([[1,2],[1,2]])

a.shape

image

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...