Skip to content

Commit

Permalink
NumPy arrays - Adding elements, Removing elements
Browse files Browse the repository at this point in the history
  • Loading branch information
oneananda committed Oct 26, 2024
1 parent 367408c commit 7116ff6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 0008-Array-NumPy/array_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@

NUMPY_ARRAY = np.array([2, 4, 6, 8, 10])
print("NumPy array:", NUMPY_ARRAY)

# Adding elements - create a new array
NEW_ARRAY = np.append(NUMPY_ARRAY, 6)
print("After appending:", NEW_ARRAY)

# Removing elements - create a new array without the specific element
NEW_ARRAY = np.delete(NUMPY_ARRAY, 2) # Deletes element at index 2 and add the result
print("After removing:", NEW_ARRAY)

0 comments on commit 7116ff6

Please sign in to comment.