Problems on Data Cleaning and Processing For Machine Learning

7 / 12

Comparing elements in Numpy arrays

In this assignment, we will create a function that takes 2 ndarrays of same size as input, checks if both of them have same elements in the same position, and returns the index of those matching elements.

INSTRUCTIONS
  • Write a function compare_ndarray
  • The function should accept 2 ndarray (arr1, and arr2) of same size as parameters
  • The function needs to compare the elements between the 2 arrays, finds the matching elements (if any) at the same position in both the arrays
  • The function should then return the index of those elements
  • Now, define 2 Numpy arrays a, and b as follows:

    a = np.array([0, 1, 2, 3, 4, 5, 6])
    b = np.array([6, 5, 4, 3, 2, 1, 6])
    
  • Use the function you just created to compare the above 2 arrays

  • The sample input and output is given below enter image description here
  • Use the Jupyter notebook given on the right side of the split screen to write your code and execute it
  • Once done, click on the Submit Answer button given above
See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...