Languages

NumPy Cheat Sheet

Print-ready cheat sheet for NumPy, organized for fast lookup, study, and desk-side use

Source
NumPy Documentation (numpy.org)
License
MIT
Variants
3 download options
Updated
2026-03-27

Sample

What's in this cheat sheet

From Lists

import numpy as np
a = np.array([1, 2, 3])        # 1D
b = np.array([[1, 2], [3, 4]])  # 2D

Built-in Constructors

np.zeros((2, 3))     # 2x3 of zeros
np.ones((3, 3))      # 3x3 of ones
np.eye(4)            # 4x4 identity matrix
np.arange(0, 10, 2)  # [0, 2, 4, 6, 8]
np.linspace(0, 1, 5) # 5 evenly spaced

Array Properties

a.shapeDimensions as tuple: `(3, 4)`
a.ndimNumber of dimensions
a.sizeTotal number of elements
a.dtypeData type: `float64`, `int32`, etc.

Download the full cheat sheet for all sections, formatted for print

Download PDF

Downloads

Choose the treatment that matches how you read

Text formats

Copy or download as plain text

Download Markdown

Best for copying commands, snippets, and config into notes, prompts, or docs

Download Markdown

Preview

The web preview is for quick browsing. The PDF remains the authoritative print artifact

Open in Browser