Learn Python Numpy Basics Cheat Sheet Part-2
Learn Python Numpy Basics Cheat Sheet Part-2
com
PYTHON FOR
DATA SCIENCE
NUMPY BASICS
CHEAT SHEET PART- 2
www.1stepgrow.com
Data Types
>>> np.int64 Signed 64-bit integer types
>>> np.float32 Standard double-precision floating point
>>> np.complex Complex numbers represented by 128 floats
>>> np.bool Boolean type storing TRUE and FALSE values
>>> np.object Python object type
>>> np.string_ Fixed-length string type
>>> np.unicode_ Fixed-length unicode type
Initial Placeholders
Initial Placeholders
>>> g = a - b array([[-0.5, 0. , 0. ], Subtraction
[-3. , -3. , -3. ]])
>>> np.subtract(a,b) Subtraction
>>> b + a array([[ 2.5, 4. , 6. ], Addition
[ 5. , 7. , 9. ]])
>>> np.add(b,a) Addition
>>> a / b array([[ 0.66666667, 1. , 1. ], Division
[ 0.25 , 0.4 , 0.5 ]])
>>> np.divide(a,b) Division
>>> a * b array([[ 1.5, 4. , 9. ], Multiplication
[ 4. , 10. , 18. ]])
>>> np.multiply(a,b) Multiplication
>>> np.exp(b) Exponentiation
>>> np.sqrt(b) Square root
>>> np.sin(a) Print sines of an array
>>> np.cos(b) Element-wise cosine
>>> np.log(a) Element-wise natural
logarithm
>>> e.dot(f) array([[ 7., 7.],
Dot product
[ 7., 7.]])
www.1stepgrow.com
Comparison
>>> a == b array([[False, True, True], Element-wise comparison
[False, False, False]], dtype=bool)
Aggregate Functions
>>> a.sum() Array-wise sum
>>> a.min() Array-wise minimum value
>>> b.max(axis=0) Maximum value of an array row
>>> b.cumsum(axis=1) Cumulative sum of the elements
>>> a.mean() Mean Mean
>>> b.median() Median
>>> a.corrcoef() Correlation coefficient
>>> np.std(b) Standard deviation
www.1stepgrow.com