Use numpy.delete(), which returns a new array with sub-arrays along an axis deleted.

numpy.delete(a, index)

For your specific question:

import numpy as np

a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])
index = [2, 3, 6]

new_a = np.delete(a, index)

print(new_a)
# Output: [1, 2, 5, 6, 8, 9]

Note that numpy.delete() returns a new array since array scalars are immutable, similar to strings in Python, so each time a change is made to it, a new object is created. I.e., to quote the delete() docs:

"A copy of arr with the elements specified by obj removed. Note that delete does not occur in-place..."

If the code I post has output, it is the result of running the code.

Answer from Levon on Stack Overflow
🌐
Stack Abuse
stackabuse.com › remove-element-from-an-array-in-python
How to Remove Elements from an Array/List in Python
September 15, 2023 - delete() is a static method declared in the numpy module. It accepts the array and the index of the element to remove. The method returns a new array without the removed element: ... There are different ways to remove a list element in Python. Sometimes we might want to remove an element by ...
Discussions

python - Removing certain element indexes in numpy array - Stack Overflow
Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... If context is king, architecture is the... AI agents are a confused deputy with the keys to your... ... 3 In a 2d numpy array, how to select every first and second element of the inner arrays? Can this be done with indexing? 12256 How can I remove ... More on stackoverflow.com
🌐 stackoverflow.com
python - Delete elements of numpy array by indexes - Stack Overflow
I'm trying to delete a few rows of Numpy Array by indexes, but I couldn't figure out why it's resulting different values. It should remove three rows. More on stackoverflow.com
🌐 stackoverflow.com
Trying to add 1 to the element at a certain index of a numpy array
You can add to any subscript of a NumPy array using +=. To a single index: a = np.zeros(7) a[1] += 1 To a range of indices: a[4:7] += 1 To a list of indices: a[[1, 6]] += 1 Or to a boolean mask: a[[False, False, False, False, False, False, True]] += 1 Depending on how you decide the positions to add to. If you select multiple positions, you can also add a different amount to each. The right-hand side must simply be broadcastable to the shape of the left-hand side: a = np.zeros(7) a += [0, 2, 0, 0, 1, 1, 3] More on reddit.com
🌐 r/learnpython
5
0
April 10, 2023
how can I remove rows from a numpy array based on a condition
You can use Boolean arrays as index masks. Say you have: >>> import numpy as np >>> M = np.array([[1,2], [3,4],[5,6]]); a = np.array([1, 3]) >>> M == a array([[ True, False], [False, False], [False, False]]) Because of the Numpy's broadcasting rules, a is compared with each row of M. We can apply some sort of reduction to each row: >>> (M == a).any(axis=1) array([ True, False, False]) In your case, you want to remove rows that match this condition, which means you want to keep rows that match the complementary condition, so one of these: >>> ~(M == a).any(axis=1) array([False, True, True]) >>> (M != a).all(axis=1) array([False, True, True]) And you can use that as an index: >>> M[(M != a).all(axis=1)] array([[3, 4], [5, 6]]) More on reddit.com
🌐 r/learnpython
2
1
February 27, 2023
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.delete.html
numpy.delete — NumPy v2.5 Manual
For a one dimensional array, this returns those entries not returned by arr[obj]. ... Input array. ... Indicate indices of sub-arrays to remove along the specified axis. Changed in version 1.19.0: Boolean indices are now treated as a mask of elements to remove, rather than being cast to the integers 0 and 1.
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to remove elements from a numpy array
5 Best Ways to Remove Elements from a NumPy Array - Be on the Right Side of Change
February 20, 2024 - Method 1: Boolean Indexing. Effective for element-based conditions. Preserves order. Can be less intuitive for those new to array operations. Method 2: NumPy’s delete() Function. Direct and built-in solution for removing by index.
🌐
Medium
medium.com › @heyamit10 › different-ways-to-remove-elements-from-a-numpy-array-59a8a7f8fe33
Different Ways to Remove Elements from a NumPy Array | by Hey Amit | Medium
April 18, 2025 - Why Provide Indices as a List? numpy.delete() is designed to accept multiple indices in list form, allowing you to specify all the elements you want to remove at once. This makes it powerful and efficient for batch removal. Now, here’s where things can get tricky. What happens if you try to remove an index ...
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-exercise-89.php
NumPy: Remove specific elements in a NumPy array - w3resource
August 29, 2025 - new_x = np.delete(x, index): Use the np.delete() function to delete the elements from 'x' at the specified indices. The result is a new array 'new_x' with the specified elements removed.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-remove-specific-elements-from-a-numpy-array
How to remove specific elements from a NumPy array ? - GeeksforGeeks
September 12, 2022 - In this article, we will discuss how to remove specific elements from the NumPy Array. The delete(array_name ) method will be used to do the same. Where array_name is the name of the array to be deleted and index-value is the index of the element ...
Find elsewhere
🌐
Codingem
codingem.com › home › numpy.delete: how to remove elements from a numpy array
numpy.delete: How to Remove Elements from a NumPy Array - codingem.com
July 10, 2025 - To remove an element from a NumPy array, use the numpy.delete(arr, index) function. This function returns a new updated version of the array.
🌐
pythontutorials
pythontutorials.net › blog › how-to-remove-specific-elements-in-a-numpy-array
How to Remove Specific Elements from a NumPy Array by Index: Step-by-Step Guide — pythontutorials.net
The most straightforward way to remove elements by index is using numpy.delete(), but we’ll also cover boolean indexing as an alternative.
🌐
Delft Stack
delftstack.com › home › howto › numpy › numpy remove element from array
How to Remove Elements From Array in NumPy | Delft Stack
February 2, 2024 - In this article, we will learn about two ways to remove elements from a NumPy array. Refer to the following code. import numpy as np myArray = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) indexes = [3, 5, 7] modifiedArray = np.delete(myArray, indexes) print(modifiedArray)
🌐
DataCamp
datacamp.com › doc › numpy › delete-numpy
NumPy delete()
import numpy as np arr = np.array([1, 2, 3, 4, 5]) new_arr = np.delete(arr, 2) print(new_arr) This example removes the element at index `2` from the 1D array, resulting in `[1, 2, 4, 5]`.
🌐
Finxter
blog.finxter.com › how-to-remove-specific-elements-in-a-numpy-array
How to Remove Specific Elements in a Numpy Array – Be on the Right Side of Change
June 3, 2022 - Summary: The most straightforward way to remove an element at a given index from a NumPy array is to call the function np.delete(array, index) that returns a new array with the element removed.
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.delete.html
numpy.delete — NumPy v2.6.dev0 Manual
For a one dimensional array, this returns those entries not returned by arr[obj]. ... Input array. ... Indicate indices of sub-arrays to remove along the specified axis. Changed in version 1.19.0: Boolean indices are now treated as a mask of elements to remove, rather than being cast to the integers 0 and 1.
🌐
Statology
statology.org › home › how to remove specific elements from numpy array
How to Remove Specific Elements from NumPy Array
August 2, 2022 - Notice that the elements in index position 0 (with value of 1) and index position 6 (with value of 9) have both been removed from the NumPy array.
🌐
Kite
kite.com › python › answers › how-to-delete-values-from-a-numpy-array-in-python
Kite is saying farewell - Code Faster with Kite
November 20, 2022 - We built the most-advanced AI for helping developers at the time, but it fell short of the 10× improvement required to break through because the state of the art for ML on code is not good enough. You can see this in Github Copilot, which is built by Github in collaboration with Open AI.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python numpy delete() function
Python NumPy delete() Function - Spark By {Examples}
March 27, 2024 - Python NumPy delete() function is used to delete elements based on index positions, and it returns a new array with the specified elements removed. For a
🌐
Programiz
programiz.com › python-programming › numpy › methods › delete
NumPy delete()
import numpy as np array1 = np.array([0, 1, 2, 3]) indices = [1, 2] # delete values at indices 1 and 2 array3 = np.delete(array1, obj = indices) print(array3) ... Similar to a 1-D array, we can delete elements from a 2-D array at any index.
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › delete
Python Numpy delete() - Remove Elements | Vultr Docs
November 6, 2024 - Here, elements at indices 1, 3, 5—corresponding to 1, 3, 5 respectively—are deleted from array_md. Specify the axis along which the deletion is to take place: 0 for rows and 1 for columns. Apply the numpy.delete() function with the appropriate ...