How to remove last element from NumPy array

You can remove the last element from the NumPy array with the following methods. If you want to learn Python, I highly recommend reading This Book.

Method 1: Remove last element from NumPy array using slicing

Python

Output:

[ 5 10 15 20 25 30 35 40 45]

Method 2: Remove last element from NumPy array using np.arange()

Python

Output:

[ 5 10 15 20 25 30 35 40 45]

Method 3: Remove last element using np.delete()

Python

Output:

[ 5 10 15 20 25 30 35 40 45]

Method 4: Remove last element using np.resize()

Python

Output:

[ 5 10 15 20 25 30 35 40 45]

Free Learning Resources

Leave a Comment

Your email address will not be published.