From 905809396fbf4baa8656a330bcea5836b61ef77d Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Fri, 15 Dec 2023 00:41:56 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- numpy/ndarray/README.md | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/numpy/ndarray/README.md b/numpy/ndarray/README.md index 819afcc..8a99720 100644 --- a/numpy/ndarray/README.md +++ b/numpy/ndarray/README.md @@ -23,6 +23,71 @@ print(b) # -> 1.0 ## [numpy.ndarray.fill​](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.fill.html) +```python +ndarray.fill(value) +``` + +> Fill the array with a scalar value. + +```python +import numpy as np +A = np.ones((3, 3)) +A.fill(7) +print(A) +``` + +Output: + +```python +[[7. 7. 7.] + [7. 7. 7.] + [7. 7. 7.]] +``` + +## [numpy.ndarray.ndim​](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.ndim.html) + +```python +ndarray.ndim +``` + +> Number of array dimensions. + +```python +import numpy as np + +A = np.ones((3, 3)) +print(A.ndim) # -> 2 +``` + +## [numpy.ndarray.shape](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.shape.html) + +```python +ndarray.shape +``` + +> Tuple of array dimensions. + +```python +import numpy as np + +A = np.ones((3, 3)) +print(A.shape) # -> (3, 3) +``` + +## [numpy.ndarray.size](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.size.html) + +```python +ndarray.size +``` + +> Number of elements in the array. + +```python +import numpy as np + +A = np.ones((3, 3)) +print(A.size) # -> 9 +``` ## [Array methods](https://numpy.org/doc/stable/reference/arrays.ndarray.html#array-methods)