0% found this document useful (0 votes)
46 views

Learn Python Numpy Basics Cheat Sheet Part-2

This document provides a summary of key NumPy functions for data analysis. It outlines NumPy data types like int64 and float32. It describes functions for inspecting arrays like shape, ndim, and dtype. It also covers initial placeholders for arithmetic operations on arrays like addition, subtraction, multiplication, and division. Finally, it discusses functions for aggregation, comparison, and statistics.

Uploaded by

garrys113
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Learn Python Numpy Basics Cheat Sheet Part-2

This document provides a summary of key NumPy functions for data analysis. It outlines NumPy data types like int64 and float32. It describes functions for inspecting arrays like shape, ndim, and dtype. It also covers initial placeholders for arithmetic operations on arrays like addition, subtraction, multiplication, and division. Finally, it discusses functions for aggregation, comparison, and statistics.

Uploaded by

garrys113
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

www.1stepgrow.

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

Inspecting Your Array


>>> a.shape Array dimensions
>>> len(a) Length of array
>>> b.ndim Number of array dimensions
>>> e.size Number of array elements
>>> b.dtype Data type of array elements
>>> b.dtype.name Name of data type
>>> b.astype(int) Convert an array to a different type

Asking For Help


>>> np.info(np.ndarray.dtype)
www.1stepgrow.com

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)

>>> a < 2 Element-wise comparison


array([True, False, False], dtype=bool)

>>> np.array_equal(a, b) Array-wise comparison

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

Build your career story with


1stepGrow Academy
Follow 1stepGrow Academy
Share your Comments

Save the Post

You might also like