Dimension in python numpy

0 votes

I am new to python and its various libraries. Currently, I am learning numpy and want to know if there is any function which will return the dimension of my array. For example:

Import numpy as np
arr=np.array([[1,2],[3,]])

I want to know its dimensions whether it’s a 2-d array or not. I even use the shape function but that could not come to my use.

Apr 19, 2018 in Python by ana1504.k
• 7,870 points
124 views

1 answer to this question.

0 votes

Use the .shape to print the dimensions of the array.

import numpy as np
arr=np.array([[1,2],[3,4]])
arr.shape

Output – (2,2)

answered Apr 19, 2018 by aayushi
• 750 points

Related Questions In Python

0 votes
1 answer

In NumPy how do I get the maximum of subsets? Python

You can use np.maximum.reduceat: >>> _, idx = np.unique(g, ...READ MORE

answered Nov 9, 2018 in Python by Nymeria
• 3,520 points
75 views
0 votes
1 answer

How to save Numpy array as image in python?

If you have matplotlib, you can do: import ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,520 points
2,338 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 330 views
+2 votes
11 answers
0 votes
1 answer

Parse JSON in Python

import json data=json.loads(employee_data) print(data) READ MORE

answered Apr 26, 2018 in Python by aayushi
• 750 points
95 views