---
source: https://iinventedlight.com/library/notes/numpy-indexing.md
title: "NumPy indexing and slicing basics"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (numpy/numpy LICENSE.txt; Copyright (c) 2005-2026, NumPy Developers; https://github.com/numpy/numpy/blob/main/LICENSE.txt); prose restates or closely paraphrases cited source lines"
license_family: numpy-bsd3
rule_check: "needs rule check (family not in auto-publish rule; check.mjs auto-approves only usgov and arxiv-ccby)"
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: NumPy"
tags: ['numpy', 'indexing', 'slicing']
sources:
  - id: S1
    title: "Indexing on ndarrays — NumPy v2.5 Manual"
    publisher: NumPy docs
    url: https://numpy.org/doc/stable/user/basics.indexing.html
    accessed: 2026-11-04
    license: "BSD-3-Clause (numpy/numpy LICENSE.txt; Copyright (c) 2005-2026, NumPy Developers; https://github.com/numpy/numpy/blob/main/LICENSE.txt)"
  - id: S2
    title: "NumPy: the absolute basics for beginners — NumPy v2.5 Manual"
    publisher: NumPy docs
    url: https://numpy.org/doc/stable/user/absolute_beginners.html
    accessed: 2026-11-04
    license: "BSD-3-Clause (numpy/numpy LICENSE.txt; Copyright (c) 2005-2026, NumPy Developers; https://github.com/numpy/numpy/blob/main/LICENSE.txt)"
---
# 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

- It is not necessary to separate each dimension's index into its own set of square brackets. (S1)
- If one indexes a multidimensional array with fewer indices than dimensions, one gets a subdimensional array. (S1)
- An element of the array can be accessed by specifying the index along each axis within a single set of square brackets, separated by commas. (S2)
- For two-dimensional arrays, a better mental model is to think of the column index as coming last and the row index as second to last. (S2)

## Slices are views

- Python slice notation can be used for indexing. (S2)
- One major difference is that slice indexing of a list copies the elements into a new list, but slicing an array returns a view: an object that refers to the data in the original array. (S2)
- The original array can be mutated using the view. (S2)
- In the subdimensional case, the returned array is a view, i.e., it is not a copy of the original, but points to the same values in memory as does the original array. (S1)

## Claims
- id: C1
  claim: NumPy indexing is 0-based and accepts negative indices.
  source: S1
  evidence: "and accepts negative indices for indexing from the end of the array."
- id: C2
  claim: Fewer indices than dimensions gives a subdimensional array.
  source: S1
  evidence: "one gets a subdimensional array."
- id: C3
  claim: Slicing an array returns a view.
  source: S2
  evidence: "but slicing an array returns a view"
- id: C4
  claim: The original array can be mutated using the view.
  source: S2
  evidence: "The original array can be mutated using the view."

## Sources
- [S1] Indexing on ndarrays — NumPy v2.5 Manual. NumPy docs. https://numpy.org/doc/stable/user/basics.indexing.html . License: BSD-3-Clause (numpy/numpy LICENSE.txt; Copyright (c) 2005-2026, NumPy Developers; https://github.com/numpy/numpy/blob/main/LICENSE.txt). Accessed 2026-11-04.
- [S2] NumPy: the absolute basics for beginners — NumPy v2.5 Manual. NumPy docs. https://numpy.org/doc/stable/user/absolute_beginners.html . License: BSD-3-Clause (numpy/numpy LICENSE.txt; Copyright (c) 2005-2026, NumPy Developers; https://github.com/numpy/numpy/blob/main/LICENSE.txt). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
