Problems on Data Cleaning and Processing For Machine Learning

11 / 12

Total number of elements (in the same position) which are different

In this assignment, we will have 2 separate Numpy arrays of same length as shown below:

import numpy as np

arr1 = np.array([1, 2, 3, 4, 6, 7])
arr2 = np.array([1, 1, 3, 6, 7, 9])

We would write a function that would take these 2 arrays (or any other 2 arrays) as parameter, and then return the total number of elements (in the same position) which are different.

INSTRUCTIONS
  • Write a function total_diff
  • The function should take 2 different Numpy arrays of same length as parameters
  • It should calculate the total number of elements in the same position in both the arrays which are of different values
  • Define the 2 arrays given above and then use the total_diff function on these 2 arrays
See Answer

No hints are availble for this assesment


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

Loading comments...