Skip to content

Commit

Permalink
[Edit] Python numpy - Added Codebyte example to append function (#5509)
Browse files Browse the repository at this point in the history
* Added Codebyte example to np append file

* lint?

* Update append.md

minor changes

---------
  • Loading branch information
selenahuang017 authored Oct 18, 2024
1 parent 801555f commit aa355c2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions content/numpy/concepts/built-in-functions/terms/append/append.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,26 @@ This produces the following output:
[4 5 6]
[7 8 9]]
```

## Codebyte Example

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
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);
```

0 comments on commit aa355c2

Please sign in to comment.