Complete the code to create a NumPy array from a Python list.
import numpy as np arr = np.[1]([1, 2, 3, 4]) print(arr)
Use np.array to create a NumPy array from a list.
Complete the code to find unique elements in a NumPy array.
import numpy as np arr = np.array([1, 2, 2, 3, 4, 4, 5]) unique_elements = np.[1](arr) print(unique_elements)
np.unique returns the sorted unique elements of an array.
Fix the error in the code to find the intersection of two NumPy arrays.
import numpy as np arr1 = np.array([1, 2, 3, 4]) arr2 = np.array([3, 4, 5, 6]) common = np.[1](arr1, arr2) print(common)
The correct NumPy function to find common elements is np.intersect1d.
Fill both blanks to create a dictionary of unique elements and their counts from a NumPy array.
import numpy as np arr = np.array([1, 2, 2, 3, 3, 3]) unique, counts = np.[1](arr, return_counts=True) result = dict(zip(unique, [2])) print(result)
np.unique with return_counts=True returns unique elements and their counts. Use counts to get counts.
Fill all three blanks to filter unique elements greater than 2 and create a dictionary with their counts.
import numpy as np arr = np.array([1, 2, 2, 3, 3, 3, 4]) unique, counts = np.unique(arr, return_counts=True) filtered = unique[unique [1] 2] filtered_counts = counts[unique [2] 2] result = dict(zip(filtered, [3])) print(result)
Use '>' to filter elements greater than 2. Use filtered_counts for counts of filtered elements.