From 9c06f6e0e697c386bcf5fc8bc92fed264f07ac15 Mon Sep 17 00:00:00 2001 From: Selena Huang Date: Wed, 16 Oct 2024 14:39:31 -0700 Subject: [PATCH 1/3] Added Codebyte example to np append file --- .../built-in-functions/terms/append/append.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/content/numpy/concepts/built-in-functions/terms/append/append.md b/content/numpy/concepts/built-in-functions/terms/append/append.md index 20069ca8e0a..b00e882601d 100644 --- a/content/numpy/concepts/built-in-functions/terms/append/append.md +++ b/content/numpy/concepts/built-in-functions/terms/append/append.md @@ -52,3 +52,26 @@ This produces the following output: [4 5 6] [7 8 9]] ``` + +## Codebyte Example + +This codebyte example will create two arrays and then append them together, illustrating the append with no axis as well as along one axis. + +```codebyte/python +import numpy as np + +nd1 = np.array([[0,0,0,0], [1,1,1,1]]) +print("First array: \n", nd1) + +nd2 = np.arange(8).reshape(2, 4) +print("Second array: \n", nd2) + +nd3 = np.append(nd1, nd2) +print("Appended array with no axis specified:\n", nd3); + +nd4 = np.append(nd1, nd2, axis = 0) +print("Appended array on axis 0:\n", nd4); + +nd5 = np.append(nd1, nd2, axis = 1) +print("Appended array on axis 1:\n", nd5); +``` From dd0fbceffc9bb9d49907b78024f2b64595cc73a2 Mon Sep 17 00:00:00 2001 From: Selena Huang Date: Wed, 16 Oct 2024 14:52:59 -0700 Subject: [PATCH 2/3] lint? --- .../numpy/concepts/built-in-functions/terms/append/append.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/numpy/concepts/built-in-functions/terms/append/append.md b/content/numpy/concepts/built-in-functions/terms/append/append.md index b00e882601d..31536b0ad91 100644 --- a/content/numpy/concepts/built-in-functions/terms/append/append.md +++ b/content/numpy/concepts/built-in-functions/terms/append/append.md @@ -69,9 +69,9 @@ print("Second array: \n", nd2) nd3 = np.append(nd1, nd2) print("Appended array with no axis specified:\n", nd3); -nd4 = np.append(nd1, nd2, axis = 0) +nd4 = np.append(nd1, nd2, axis = 0) print("Appended array on axis 0:\n", nd4); -nd5 = np.append(nd1, nd2, axis = 1) +nd5 = np.append(nd1, nd2, axis = 1) print("Appended array on axis 1:\n", nd5); ``` From e1ae1c1c8e9ecf31784ce3b523e87bcc5f389dbd Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Thu, 17 Oct 2024 16:16:44 +0530 Subject: [PATCH 3/3] Update append.md minor changes --- .../numpy/concepts/built-in-functions/terms/append/append.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/numpy/concepts/built-in-functions/terms/append/append.md b/content/numpy/concepts/built-in-functions/terms/append/append.md index 31536b0ad91..ae1bc35378d 100644 --- a/content/numpy/concepts/built-in-functions/terms/append/append.md +++ b/content/numpy/concepts/built-in-functions/terms/append/append.md @@ -55,7 +55,7 @@ This produces the following output: ## Codebyte Example -This codebyte example will create two arrays and then append them together, illustrating the append with no axis as well as along one axis. +The following example creates two arrays and demonstrates appending them using `.append()`, both without specifying an axis (resulting in a 1D array) and along specified axes (rows and columns): ```codebyte/python import numpy as np