Question: Use Python 3 in Jupyter Write a function called countUnique that has one parameter which is a NumPy array. The array will be a list
Use Python 3 in Jupyter
Write a function called countUnique that has one parameter which is a NumPy array. The array will be a list of integers with many repeated values. The function should count how many times each unique integer appears and return the counts. For example, if it is given the array array([3, 3, 3, 1, 1, 3, 1, 1, 3, 2]), it should return the counts [(1, 4), (2, 1), (3, 5)] since 1 appears 4 times, 2 appears once, and 3 appears 5 times.
In a separate code cell, create an create a NumPy array of 20 random integers from 1 to 20. Use your countUnique to determine how many times each number appears.
In a separate code cell, create an create a NumPy array of 10,000 random integers from 1 to 5. Use your countUnique to determine how many times each number appears.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
