|
1 |
| -.. for doctests |
2 |
| - >>> import numpy as np |
3 |
| -
|
| 1 | +.. _routines.indexing: |
4 | 2 | .. _arrays.indexing:
|
5 | 3 |
|
6 |
| -******** |
7 |
| -Indexing |
8 |
| -******** |
9 |
| - |
10 |
| -.. seealso:: |
11 |
| - |
12 |
| - :ref:`basics.indexing` |
13 |
| - |
14 |
| - :ref:`Indexing routines <routines.indexing>` |
15 |
| - |
16 |
| -Array indexing refers to any use of the square brackets ([]) to index |
17 |
| -array values. There are many options to indexing, which give NumPy |
18 |
| -indexing great power, but with power comes some complexity and the |
19 |
| -potential for confusion. This section is just an overview of the |
20 |
| -various options and issues related to indexing. Further details can be |
21 |
| -found in the relevant sections of :ref:`basics.indexing`. |
22 |
| - |
23 |
| - |
24 |
| -Basic indexing |
25 |
| -============== |
26 |
| - |
27 |
| -Basic indexing will be triggered through single element indexing or |
28 |
| -slicing and striding. |
29 |
| - |
30 |
| -Single element indexing works |
31 |
| -exactly like that for other standard Python sequences but has been expanded |
32 |
| -to support multidimensional indexing |
33 |
| -for multidimensional NumPy arrays. For more details and examples, see |
34 |
| -:ref:`single-element-indexing`. |
35 |
| - |
36 |
| -It is possible to slice and stride arrays to extract arrays of the |
37 |
| -same number of dimensions, but of different sizes than the original. |
38 |
| -The slicing and striding work exactly the same way it does for lists |
39 |
| -and tuples except that they can be applied to multiple dimensions as |
40 |
| -well. See :ref:`basic-slicing-and-indexing` for more information and examples. |
41 |
| - |
42 |
| - |
43 |
| -Advanced indexing |
| 4 | +Indexing routines |
44 | 5 | =================
|
45 | 6 |
|
46 |
| -Arrays can be indexed with other arrays to |
47 |
| -select lists of values out of arrays into new arrays. There are |
48 |
| -two different ways of accomplishing this. One uses one or more arrays |
49 |
| -of index values. The other involves giving a boolean array of the proper |
50 |
| -shape to indicate the values to be selected. Index arrays are a very |
51 |
| -powerful tool that allows one to avoid looping over individual elements in |
52 |
| -arrays and thus greatly improve performance. See :ref:`advanced-indexing` |
53 |
| -for more information and examples. |
54 |
| - |
55 |
| - |
56 |
| -Other indexing options |
57 |
| -====================== |
58 |
| - |
59 |
| -:ref:`arrays.indexing.fields`, :ref:`flat-iterator-indexing` are a couple |
60 |
| -of other indexing options. |
| 7 | +.. seealso:: :ref:`basics.indexing` |
| 8 | + |
| 9 | +.. currentmodule:: numpy |
| 10 | + |
| 11 | +Generating index arrays |
| 12 | +----------------------- |
| 13 | +.. autosummary:: |
| 14 | + :toctree: generated/ |
| 15 | + |
| 16 | + c_ |
| 17 | + r_ |
| 18 | + s_ |
| 19 | + nonzero |
| 20 | + where |
| 21 | + indices |
| 22 | + ix_ |
| 23 | + ogrid |
| 24 | + ravel_multi_index |
| 25 | + unravel_index |
| 26 | + diag_indices |
| 27 | + diag_indices_from |
| 28 | + mask_indices |
| 29 | + tril_indices |
| 30 | + tril_indices_from |
| 31 | + triu_indices |
| 32 | + triu_indices_from |
| 33 | + |
| 34 | +Indexing-like operations |
| 35 | +------------------------ |
| 36 | +.. autosummary:: |
| 37 | + :toctree: generated/ |
| 38 | + |
| 39 | + take |
| 40 | + take_along_axis |
| 41 | + choose |
| 42 | + compress |
| 43 | + diag |
| 44 | + diagonal |
| 45 | + select |
| 46 | + lib.stride_tricks.sliding_window_view |
| 47 | + lib.stride_tricks.as_strided |
| 48 | + |
| 49 | +Inserting data into arrays |
| 50 | +-------------------------- |
| 51 | +.. autosummary:: |
| 52 | + :toctree: generated/ |
| 53 | + |
| 54 | + place |
| 55 | + put |
| 56 | + put_along_axis |
| 57 | + putmask |
| 58 | + fill_diagonal |
| 59 | + |
| 60 | +Iterating over arrays |
| 61 | +--------------------- |
| 62 | +.. autosummary:: |
| 63 | + :toctree: generated/ |
| 64 | + |
| 65 | + nditer |
| 66 | + ndenumerate |
| 67 | + ndindex |
| 68 | + nested_iters |
| 69 | + flatiter |
| 70 | + lib.Arrayterator |
0 commit comments