# Numpy array dimensions

###### Posted By: Anonymous

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 `a`

(e.g.a is a 2 by 2 array)?

`size()`

returns 4 and that doesn’t help very much.

## Solution

It is `.shape`

:

ndarray.

shape

Tuple of array dimensions.

Thus:

```
>>> a.shape
(2, 2)
```

###### Answered By: Anonymous

### Related Articles

- Can't install via pip because of egg_info error
- What is the difference between Numpy's array() and…
- What's the difference between eval, exec, and compile?
- AppCompat v7 r21 returning error in values.xml?
- Keras input explanation: input_shape, units,…
- From ND to 1D arrays
- How to "properly" create a custom object in JavaScript?
- How to write a multidimensional array to a text file?
- python how to pad numpy array with zeros
- Python-coded neural network does not learn properly
- Python 3.9+ typing.Collection vs tuple vs typing.Iterable
- How do I merge two dictionaries in a single…
- How to fix Python Numpy/Pandas installation?
- How to update Python?
- How to overwrite operator in C++ class with a…
- Difference between numpy.array shape (R, 1) and (R,)
- Usage of __slots__?
- numpy matrix vector multiplication
- How do SO_REUSEADDR and SO_REUSEPORT differ?
- Assigning values to tuple in for loop
- Convert a numpy.ndarray to string(or bytes) and…
- What are "named tuples" in Python?
- Detect if a NumPy array contains at least one…
- Install pip in docker
- Converting between datetime, Timestamp and datetime64
- initialize a numpy array
- Text size and different android screen sizes
- How do I find the length (or dimensions, size) of a…
- Converting numpy dtypes to native python types
- Append a tuple to a list - what's the difference…
- Unresponsive hamburger icon in HTML
- How to add column to numpy array
- how to Display Tuple{Float64, Bool}
- What is your most productive shortcut with Vim?
- Why does this code work in Fabric js version 3.6.6…
- RNN LSTM valueError while training
- Convert RGBA PNG to RGB with PIL
- Remove similar tuple from dictionary of tuples
- Can't import Numpy in Python
- load csv into 2D matrix with numpy for plotting
- Throw HttpResponseException or return…
- Convert ndarray from float64 to integer
- Relative imports for the billionth time
- JavaScript OOP in NodeJS: how?
- Getting started with Haskell
- How to create a class of classes
- How do I expand the output display to see more…
- Are dictionaries ordered in Python 3.6+?
- Create numpy matrix filled with NaNs
- Index of element in NumPy array
- Class is not abstract and does not override abstract method
- PyTorch: How to get the shape of a Tensor as a list of int
- python dict to numpy structured array
- How do I install SciPy on 64 bit Windows?
- What does Ruby have that Python doesn't, and vice versa?
- After using pip, I get the error "Scikit-learn has…
- Convert numpy array to tuple
- Better way to shuffle two numpy arrays in unison
- Trouble with qsort with key/value structs in a btree
- How to compute the similarity between two text documents?
- Managing longs and short orders like LucF PineCoders…
- How to calculate the sum of all columns of a 2D…
- Sorting arrays in NumPy by column
- How to sum each table of values in each index…
- How to split/partition a dataset into training and…
- How can I wrap all BeautifulSoup existing…
- TypeScript metadata reflection references other…
- Convert list to tuple in Python
- Printing tuple with string formatting in Python
- Reference - What does this regex mean?
- How to prevent scrolling the whole page?
- How to count the occurrence of certain item in an ndarray?
- Python - AttributeError: 'numpy.ndarray' object has…
- Why does .loc not always match column names?
- What are type hints in Python 3.5?
- data.table vs dplyr: can one do something well the…
- ValueError: could not broadcast input array from…
- Replacing a 32-bit loop counter with 64-bit…
- Haskell data type within data type
- TypeError: unhashable type: 'numpy.ndarray'
- Change a function's return type based on size of std::tuple
- Install opencv for Python 3.3
- Is there a standardized method to swap two variables…
- How to build an array of Objects in a loop
- How can I upgrade NumPy?
- index in a tuple of a dictionaries python
- Is it possible to declare two variables of different…
- Fastest way to list all primes below N
- Auto-fit TextView for Android
- What's the best way of scraping data from a website?
- How do you read a Python Traceback error?
- How can I install a previous version of Python 3 in…
- How does tuple comparison work in Python?
- How do I calculate r-squared using Python and Numpy?
- Custome drawable Shape android
- Add dates in format YY-MM-DD for each row of an…
- why numpy.ndarray is object is not callable in my…
- Tuple unpacking in for loops
- What's the difference between lists and tuples?
- Converting string to tuple without splitting characters

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.