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 20, 2018 in Python by ana1504.k
• 7,910 points
745 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 20, 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,560 points
1,593 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,560 points
8,949 views
0 votes
1 answer
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+1 vote
12 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
1,246 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP