Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Edit] Python numpy - Added Codebyte example to append function #5509

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
```
Loading