append() creates a new array which can be the old array with the appended element.

I think it's more normal to use the proper method for adding an element:

a = numpy.append(a, a[0])
Answer from steabert on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › numpy › how-to-add-a-new-value-to-a-numpy-array
How to Add a New Value to a NumPy Array - GeeksforGeeks
July 23, 2025 - import numpy as np arr = np.array([1, 2, 3]) # Insert a new value at index 1 new_arr = np.insert(arr, 1, 4) print(new_arr) ... The np.concatenate() function can be used to add elements by combining two arrays.
🌐
DataCamp
datacamp.com › doc › numpy › append
NumPy append()
NumPy's `append()` function is used to add elements to the end of an existing array, effectively creating a new array with the additional elements.
🌐
Vultr Docs
docs.vultr.com › python › third party › numpy › append()
Python Numpy append() - Add Elements to Array
April 10, 2025 - Plan to append elements to this array. ... Use numpy.append() to add a single element or multiple elements.
🌐
Statology
statology.org › home › how to add elements to numpy array (3 examples)
How to Add Elements to NumPy Array (3 Examples)
June 15, 2022 - You can use the following methods to add one or more elements to a NumPy array: ... #insert 95 and 99 starting at index position 2 of the NumPy array new_array = np.insert(my_array, 2, [95, 99])
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Insert elements, rows, and columns into an array with np.insert() | note.nkmk.me
March 22, 2023 - In NumPy, you can insert elements, rows, or columns into an array (ndarray) using the np.insert() function. numpy.insert — NumPy v1.24 Manual This article describes the following contents. Overview o ...
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.append.html
numpy.append — NumPy v2.6.dev0 Manual
>>> a = np.array([1, 2], dtype=np.int_) >>> c = np.append(a, []) >>> c array([1., 2.]) >>> c.dtype float64
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: append() to add values to an array | note.nkmk.me
February 4, 2024 - In NumPy, the np.append() function allows you to add values (elements, rows, or columns) to either the end or the beginning of an array (ndarray).
Find elsewhere
🌐
Nanyang Technological University
libguides.ntu.edu.sg › python › addelementstoarrays
NP.8 Adding elements to arrays - Python for Basic Data Analysis - LibGuides at Nanyang Technological University
August 26, 2026 - NP.14 NumPy Exercises · Learning ... you can use np.append · Syntax · np.append(ndarray, elements you want to add, axis) axis = 0 is row (will be added to the bottom most row) axis = 1 is column (will be added to right most column) 1D arrays (Single) 1D arrays (Multiple) 2D arrays (Rows) 2D arrays (Columns) Let's start with an array called x and add an integer to the end of the array ...
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.append.html
numpy.append — NumPy v2.5 Manual
>>> a = np.array([1, 2], dtype=np.int_) >>> c = np.append(a, []) >>> c array([1., 2.]) >>> c.dtype float64
🌐
Centron
centron.de › home › tutorials › how to add elements to an array in python
How To Add Elements to an Array in Python – centron
December 6, 2024 - You can append an array with columns that are two rows high to another array with columns that are two rows high. The following example demonstrates how to add elements to a NumPy array using the numpy.append() function:
🌐
DataCamp
datacamp.com › doc › numpy › insert-numpy
NumPy insert()
The insert() operation is used when you want to add elements into a NumPy array without modifying the original array.
🌐
Medium
giulio-laurenti.medium.com › how-to-add-and-remove-elements-from-numpy-arrays-935517220b5b
How to Add and Remove Elements from NumPy Arrays | by Giulio Laurenti, PhD | Medium
October 18, 2024 - Before we start, let’s import Numpy as np. ... The axis parameter is only relevant for arrays with two or more dimensions. Let’s start with appending elements to 1D arrays. # Create a 1D array containing 4 random integers between 20 and 80. arr = np.random.randint(20, 80, size = 4) arr array([51, 28, 21, 27]) # Now let's append the number 62 at the end of the array np.append(arr, 62) array([51, 28, 21, 27, 62])
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_append.htm
Numpy Append() Method
import numpy as np a = np.array([[1,2,3],[4,5,6]]) print('First array:') print(a) print('\n') print('Append elements to array:') print(np.append(a, [7,8,9])) print('\n') print('Append elements along axis 0:') print(np.append(a, [[7,8,9]],axis = 0)) print('\n') print('Append elements along axis 1:') print(np.append(a, [[5,5,5],[7,8,9]],axis = 1))
🌐
Vultr Docs
docs.vultr.com › python › third party › numpy › insert()
Python Numpy insert() - Insert Elements
November 15, 2024 - Explore various examples that ... of your original data array. Import the NumPy library. Define an initial array. Use numpy.insert() to add an element at a desired index....
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.append.html
numpy.append — NumPy v2.3 Manual
>>> a = np.array([1, 2], dtype=int) >>> c = np.append(a, []) >>> c array([1., 2.]) >>> c.dtype float64
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.insert.html
numpy.insert — NumPy v2.5 Manual
>>> import numpy as np >>> a = np.arange(6).reshape(3, 2) >>> a array([[0, 1], [2, 3], [4, 5]]) >>> np.insert(a, 1, 6) array([0, 6, 1, 2, 3, 4, 5]) >>> np.insert(a, 1, 6, axis=1) array([[0, 6, 1], [2, 6, 3], [4, 6, 5]])
🌐
pythontutorials
pythontutorials.net › blog › adding-element-to-numpy-array
Adding Elements to NumPy Arrays: A Comprehensive Guide — pythontutorials.net
For example, you might be collecting ... data points new_data = np.array([40, 50]) # Add new data to the existing array arr = np.append(arr, new_data) print("Array after adding new data:", arr)...
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.add.html
numpy.add — NumPy v2.2 Manual
The sum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars. ... Equivalent to x1 + x2 in terms of array broadcasting. ... >>> import numpy as np >>> np.add(1.0, 4.0) 5.0 >>> x1 = np.arange(9.0).reshape((3, 3)) >>> x2 = np.arange(3.0) >>> np.add(x1, x2) array([[ 0., 2., 4.], [ 3., 5., 7.], [ 6., 8., 10.]])