From e6ee924a22af3f13359e9c0881bfcc87cf16c132 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 30 Dec 2023 17:00:30 +0100 Subject: [PATCH] Create README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- numpy/ndenumerate/README.md | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 numpy/ndenumerate/README.md diff --git a/numpy/ndenumerate/README.md b/numpy/ndenumerate/README.md new file mode 100644 index 0000000..be3795a --- /dev/null +++ b/numpy/ndenumerate/README.md @@ -0,0 +1,56 @@ +# ndenumerate +{:.no_toc} + + + +## Top + +Questions to [David Rotermund](mailto:davrot@uni-bremen.de) + + +## [numpy.ndenumerate](https://numpy.org/doc/stable/reference/generated/numpy.ndenumerate.html) + +```python +class numpy.ndenumerate(arr) +``` + +> Multidimensional index iterator. +> +> Return an iterator yielding pairs of array coordinates and values. + + +```python +import numpy as np + +a = np.arange(0, 12).reshape((4, 3)) +print(a) +print() + +for index, x in np.ndenumerate(a): + print(index, x) +``` + +Output: + +```python +[[ 0 1 2] + [ 3 4 5] + [ 6 7 8] + [ 9 10 11]] + +(0, 0) 0 +(0, 1) 1 +(0, 2) 2 +(1, 0) 3 +(1, 1) 4 +(1, 2) 5 +(2, 0) 6 +(2, 1) 7 +(2, 2) 8 +(3, 0) 9 +(3, 1) 10 +(3, 2) 11 +```