Numpy Cheat Sheet & Quick Reference
Numpy Cheat Sheet & Quick Reference
Ads by
Send feedback
AI Excel Course Just ₹99
Why this ad?
Numpy
NumPy is the fundamental package for scientific computing with Python. This cheat sheet is a quick reference for NumPy beginners.
# Getting Started
Introduction
import numpy as np
Importing/exporting
Creating Arrays
https://quickref.me/numpy 1/5
10/01/2025, 00:05 Numpy Cheat Sheet & Quick Reference
np.arange(0,10,3) Array of values from 0 to less than 10 with step 3 (eg [0,3,6,9])
Inspecting Properties
Copying/sorting/reshaping
arr.resize((5,6)) Changes arr shape to 5x6 and fills new values with 0
Adding/removing Elements
Combining/splitting
https://quickref.me/numpy 2/5
10/01/2025, 00:05 Numpy Cheat Sheet & Quick Reference
Indexing/slicing/subsetting
arr[0:3] Returns the elements at indices 0,1,2 (On a 2D array: returns rows 0,1,2)
arr[:2] Returns the elements at indices 0,1 (On a 2D array: returns rows 0,1)
Vector Math
np.array_equal(arr1,arr2) Returns True if the arrays have the same elements and shape
Scalar Math
np.divide(arr,4) Divide each array element by 4 (returns np.nan for division by zero)
https://quickref.me/numpy 3/5
10/01/2025, 00:05 Numpy Cheat Sheet & Quick Reference
Statistics
India to Dubai
from Rs14,838
from India
Search
India to Malaysia
from Rs5,488
from India
Search
India to Thailand
from Rs12,110
from India
Search
Mumbai to Goa
from Rs4,646
from Mumbai
Search
Top Cheatsheet
Recent Cheatsheet
https://quickref.me/numpy 4/5