forked from Arman2106/web-scrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumpy.py
72 lines (56 loc) · 928 Bytes
/
numpy.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#numpy basics
import numpy as np
#creating an array
a = np.array([1,2,3])
print(a) #[1 2 3]
#numpy methods
#array
#zeros
#ones
#empty
#arange
#linspace
#random.rand
#random.randn
#random.randint
#reshape
#ravel
#min
#max
#argmin
#argmax
#shape
#dtype
print()
#creating a 2D array
b = np.array([[1,2,3],[4,5,6]])
print(b)
#[[1 2 3]
# [4 5 6]]
print()
#creating a 3D array
c = np.array([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]])
print(c)
#[[[ 1 2 3]
# [ 4 5 6]]
# [[ 7 8 9]
# [10 11 12]]]
print()
#creating an array with a specified datatype
d = np.array([1,2,3], dtype=complex)
print(d) #[1.+0.j 2.+0.j 3.+0.j]
print()
#creating an array with zeros
e = np.zeros((3,3))
print(e)
#[[0. 0. 0.]
# [0. 0. 0.]
# [0. 0. 0.]]
print()
#creating an array with ones
f = np.ones((3,3))
print(f)
#[[1. 1. 1.]
# [1. 1. 1.]
# [1. 1. 1.]]
print()