-
Notifications
You must be signed in to change notification settings - Fork 0
/
NumPy.py
106 lines (43 loc) · 1.03 KB
/
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 18 17:10:25 2018
@author: KarthikM
"""
import numpy as np
x = np.array([1,2,3])
print(x.dtype)
x = np.array([1,2,3.0])
print(x.dtype)
x = np.array([1,2,3,4,5],ndmin=2)
print(x.shape)
x = np.array([1,2,3,4,5],ndmin=3)
print(x.shape)
x= np.arange(10)
s = slice(3,9,2)
print(x[s])
print(x[3:9:1])
print(x[:7])
print(x[3:]) # from 3 to last
x = np.array([[1,2,3],[4,5,6],[7,8,9]])
print(x)
print(x[1:]) # row of index 1 and 2 will be printed
# To print column
print(x[:,1]) #print 1st column
x = [1,2,3]
y = [4,5,6]
print(x+y)
#numpy
x = np.array([1,2,3])
y = np.array([4,5,6])
print(x+y)
x = np.array([1,2,3,4,5,6,7,8,9,10])
print(np.mean(x))
print(np.min(x))
print(np.max(x))
print(np.var(x))
print(np.std(x))
print(np.argmax(x))
print(np.argmin(x))
print(np.where(x>3))
condition = (x>3) & (x<9)
print(np.extract(condition,x))