numpynotes.
md 2025-05-16
Nice! Since you’re diving into a full NumPy course, here’s a structured note in Markdown format (can be
converted to HTML, LaTeX, or PDF later if you want). It's beginner-friendly, organized, and useful as a cheat
sheet or study guide:
📊 NumPy Full Course Notes
🔧 What is NumPy?
NumPy is a Python library used for scientific computing.
Fundamental for many other libraries like pandas, scikit-learn, and TensorFlow.
Works with multi-dimensional arrays and provides powerful methods to operate on them.
⚡ Why Use NumPy Over Lists?
Feature Python Lists NumPy Arrays
Speed Slower Much faster
Memory Uses more memory Uses less memory
Type-checking Dynamic Fixed (int32, float64, etc.)
Memory layout Scattered Contiguous
NumPy arrays allow vectorized operations, utilize SIMD and cache better.
🛠 Array Initialization
import numpy as np
# 1D Array
a = [Link]([1, 2, 3])
# 2D Array
b = [Link]([[1.1, 2.2, 3.3], [4.4, 5.5, 6.6]])
# Zeros, Ones, Full
[Link]((2, 3))
[Link]((3, 3), dtype='int32')
[Link]((2, 2), 99)
# Identity Matrix
[Link](3)
# Random Arrays
[Link](4, 2) # Random floats (0 to 1)
[Link](0, 10, (3, 3)) # Random integers
1/4
[Link] 2025-05-16
🔍 Array Properties
[Link] # (3,)
[Link] # 1
[Link] # int32, float64, etc.
[Link] # Number of elements
[Link] # Bytes per element
[Link] # Total bytes
🔄 Reshape, Copy & Repeat
[Link](2, 3) # Change shape
[Link](a, 3, axis=0) # Repeat elements
[Link]() # Deep copy to avoid pointer issues
🔢 Indexing & Slicing
a[0, 1] # Element at row 0, column 1
a[:, 2] # All rows, column 2
a[1, 1:-1:2] # Fancy slicing
a[1:3, 2:5] # Submatrix
➕ Math Operations
a + 10
a * 2
a ** 2
[Link](a)
[Link](a)
🧮 Linear Algebra
a @ b # Matrix multiplication
[Link](a, b)
[Link](a) # Determinant
2/4
[Link] 2025-05-16
[Link](a) # Inverse
[Link](a) # Eigenvalues
📊 Statistics
[Link](a)
[Link](a)
[Link](a)
[Link](a)
[Link](a)
[Link](a)
Use axis=0 for columns, axis=1 for rows.
📂 Load from File
data = [Link]("[Link]", delimiter=',')
data = [Link](np.int32) # Convert type
🧠 Advanced Indexing
mask = a > 50
a[mask] # Filtered values
# Combining Conditions
a[(a > 50) & (a < 100)]
# Index with list
a[[0, 2, 4]]
📦 Stacking & Reorganizing
[Link]([a, b]) # Vertical stack
[Link]([a, b]) # Horizontal stack
🧪 Quizzes (Practice Time!)
Try slicing:
3/4
[Link] 2025-05-16
Get submatrix: rows 1 to 2, columns 0 to 1
Select odd-indexed rows
Reverse columns using slicing
If you'd like this converted to HTML, LaTeX, or a downloadable PDF, just say the word and I’ll prep it! Also, we
can turn these into flashcards, mini-projects, or quizzes if you want to test your knowledge. Up for it? 😊
4/4