- Notifications
You must be signed in to change notification settings - Fork 638
Expand file tree
/
Copy pathP03_NumpyAttributes.py
More file actions
Latest commit
24 lines (16 loc) · 610 Bytes
/
Copy pathP03_NumpyAttributes.py
File metadata and controls
24 lines (16 loc) · 610 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Author: OMKAR PATHAK
# These are the various attributes provided by NumPy.
importnumpyasnp
myArray=np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(myArray)
# [[1 2 3]
# [4 5 6]
# [7 8 9]]
# ndarray.size returns the number of items in the array
print(myArray.size) # 9
# ndarray.shape returns a tuple consisting of array dimensions
print(myArray.shape) # (3, 3)
# ndarray.ndim returns the number of array dimensions
print(myArray.ndim) # 2
# ndarray.itemsize returns the memory size of each element in the array
print(myArray.itemsize) # 8