← All notes

NumPy indexing and slicing basics

Answer: ndarrays can be indexed using the standard Python x[obj] syntax, where x is the array and obj the selection. Single element indexing works exactly like that for other standard Python sequences: it is 0-based, and accepts negative indices for indexing from the end of the array. (S1)

Multiple dimensions

Slices are views

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: NumPy docs, Indexing on ndarrays — NumPy v2.5 Manual, BSD-3-Clause (numpy/numpy LICENSE.txt; Copyright (c) 2005-2026, NumPy Developers; https://github.com/numpy/numpy/blob/main/LICENSE.txt); NumPy docs, NumPy: the absolute basics for beginners — NumPy v2.5 Manual, BSD-3-Clause (numpy/numpy LICENSE.txt; Copyright (c) 2005-2026, NumPy Developers; https://github.com/numpy/numpy/blob/main/LICENSE.txt).

Cite this

Permanent ID: iil:note:6jvjq31g

iinventedlight. 2026. "NumPy indexing and slicing basics." iinventedlight Library, iil:note:6jvjq31g, version of 2026-11-04. https://iinventedlight.com/library/notes/numpy-indexing/. License: CC-BY-4.0.

@misc{iil_note_6jvjq31g,
  author = {{iinventedlight}},
  title = {{NumPy indexing and slicing basics}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/numpy-indexing/},
  note = {Permanent ID iil:note:6jvjq31g. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/numpy-indexing.md.