NumPy Cheat Sheet
Decoding Data Science
NumPy Cheat Sheet
Decoding Data Science
1. Basic Commands
NumPy is a Python library used for working with arrays. It also has functions for working in domain
of linear algebra, fourier transform, and matrices.
- Importing NumPy:
import numpy as np
- Checking NumPy version:
print(np.__version__)
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
2. Array Creation
In NumPy, arrays are the main way you will use NumPy. There are several ways to create arrays.
- From a list:
my_list = [1, 2, 3, 4, 5]
arr = [Link](my_list)
- With initial placeholders:
arr_zeroes = [Link]((3, 3))
arr_ones = [Link]((3, 3))
arr_random = [Link]((3,3))
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
3. Array Attributes
NumPy arrays have many useful attributes.
- Shape:
[Link]
- Data type:
[Link]
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
4. Indexing and Slicing
NumPy offers several ways to index into arrays.
- One-dimensional arrays:
arr[0]
arr[:2]
- Multi-dimensional arrays:
arr[0, 1]
arr[:, 1]
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
5. Array Manipulation
NumPy provides many functions to manipulate arrays.
- Reshaping:
[Link]((3, 3))
- Stacking:
[Link]((arr1, arr2))
[Link]((arr1, arr2))
- Splitting:
[Link](arr, 3)
[Link](arr, 3)
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
6. Arithmetic Operations
NumPy provides standard arithmetic operations.
- Addition, subtraction, multiplication, division:
arr1 + arr2
arr1 - arr2
arr1 * arr2
arr1 / arr2
- Matrix operations:
[Link](arr1, arr2)
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
7. Statistical Operations
NumPy provides many useful functions to perform statistical operations on arrays.
- Mean:
[Link](arr)
- Median:
[Link](arr)
- Standard deviation:
[Link](arr)
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
8. Trigonometric Functions
NumPy provides the ufuncs sin(), cos() and tan() that take values in radians and produce the
corresponding sin, cos and tan values.
- Sine, cosine, tangent:
[Link](arr)
[Link](arr)
[Link](arr)
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
9. Linear Algebra
NumPy provides the function dot() that returns the dot product of two arrays. Furthermore, NumPy
provides many functions to compute the determinant, trace, eigenvalues, and more.
- Dot product:
[Link](arr1, arr2)
- Inverse:
[Link](arr)
- Eigenvalues and eigenvectors:
[Link](arr)
Join our AI community: [Link]
NumPy Cheat Sheet
Decoding Data Science
Join Our AI Community
Being part of an AI community like ours offers multiple benefits. You can network with like-minded
individuals, learn from experienced professionals, and stay up-to-date with the latest AI trends and
developments.
Whether you're a beginner looking to start your journey in AI, or an experienced professional looking
to enhance your skills, our community has something to offer.
Join us and be a part of this exciting journey. Learn more, grow more!
Click the link in the footer to join us today!
Join our AI community: [Link]