Skip to content

Commit 6de48cb

Browse files
committed
Numpy Array Attributes
1 parent ff2651e commit 6de48cb

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Numpy/P03_NumpyAttributes.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Author: OMKAR PATHAK
2+
3+
# These are the various attributes provided by NumPy.
4+
5+
import numpy as np
6+
7+
myArray = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
8+
print(myArray)
9+
10+
# [[1 2 3]
11+
#  [4 5 6]
12+
#  [7 8 9]]
13+
14+
# ndarray.size returns the number of items in the array
15+
print(myArray.size) # 9
16+
17+
# ndarray.shape returns a tuple consisting of array dimensions
18+
print(myArray.shape) # (3, 3)
19+
20+
# ndarray.ndim returns the number of array dimensions
21+
print(myArray.ndim) # 2
22+
23+
# ndarray.itemsize returns the memory size of each element in the array
24+
print(myArray.itemsize) # 8

0 commit comments

Comments
 (0)