Published on January 26, 2024By DeveloperBreeze

import numpy as np

# Create a NumPy array of integers
arr = np.array([10, 20, 30, 40, 50])

# Use boolean indexing to filter elements greater than 30
filtered_arr = arr[arr > 30]
print("Filtered Array (elements > 30):", filtered_arr)

# Use integer indexing to select elements at specific indices
selected_indices = [0, 2, 4]
selected_elements = arr[selected_indices]
print("Selected Elements (by index):", selected_elements)

Comments

Please log in to leave a comment.

Continue Reading:

Append Data to JSON File

Published on January 26, 2024

jsonpython

Create and Save Random Color Grid as PNG Image

Published on January 26, 2024

python

Calculate Mean and Standard Deviation of NumPy Array

Published on January 26, 2024

python

Reshape NumPy Array

Published on January 26, 2024

python

Create a NumPy 1D Array

Published on January 26, 2024

python

Calculate Sum of Numbers in Array

Published on January 26, 2024

csharp

Remove Duplicates from Array Using Set

Published on January 26, 2024

javascript

Find Maximum Number in Array Using Math.max

Published on January 26, 2024

javascript

Find Maximum Number in List Using max() Function

Published on January 26, 2024

python