-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy_4.py
More file actions
37 lines (28 loc) · 888 Bytes
/
py_4.py
File metadata and controls
37 lines (28 loc) · 888 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
25
26
27
28
29
30
31
32
33
34
35
36
37
import numpy as np
print("Copy array operation ")
a = np.array([1,2,3])
copy1 = a.copy()
a[2] = 10
print(a)
print(copy1)
print("View array operation ...It's one type of cloning")
view1 = a.view()
a[2] = 10
print(a)
print(view1)
print("Shape array operation ")
arr1 = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
print("Shape of array :",arr1.shape)
print("Reshape array operation ")
arr = np.array([1,2,3,4,5,6,7,8,9,10,11,12])
reshape_array = arr.reshape(3,4)
reshape_array1 = arr.reshape(3,2,2)
print("2-D array..\n",reshape_array)
print("3-D array ..\n",reshape_array1)
print("Flatten array operation..")
print("Given array\n",reshape_array1)
print("Flatten array\n ", reshape_array1.flatten())
print("Flatten array operation.. example ")
array = np.arange(15).reshape(3, 5)
print("Given array\n",array)
print("Flatten array \n", array.flatten())