Write code in PYTHON3. Create a function clear_number(data), which…

Question Answered step-by-step Write code in PYTHON3. Create a function clear_number(data), which… Write code in PYTHON3.Create a function clear_number(data), which takes a dictionary of data in the format the returned by read_data. The data is read from a csv file, contains ID (recorded by row number), course (course taking), and stdnum (student number). The data is noisy, and should be modify.1. The student number should be a 4-digit integer, and start with 3. Some student numbers doesn’t meet the requirement, so they should be replace by None.2. Some values in course taking are spelt incorrectly. The valid course is in the list VALID_COURSE, which is given. You should change the incorrect values to the values in list VALID_COURSE that has the highest similarity.For example, str1 = “XxX yYY zzZ”, str2 = “zzz YyY RRR”. The set of str1 should be s1 = {‘x’, ‘y’, ‘z’,’ ‘ } (including space), and the set of str2 should be s2 = {‘z’, ‘y’, ‘r’, ‘ ‘} (including space), all upper case can be considered as lower case, which are the same. The formula of set similarity (Sim) for str1 and str2 is Sim(str1, str2) = |S1∩S2|/|S1∪S2|, |x| is the length of set x. For this example, Sim(str1, str2) = |{x,y,z,(space)}∩{z,y,r,(space)}| / |x,y,z,(space)}∪{z,y,r,(space)}| = |{y,z,(space)}| / |{x,y,z,r,(space)}| = 3/5 = 0.6.Create a function Sim() to replace the invalid values to the values in list VALID_COURSE with the highest similarity. If invalid values have same similarities with 2 or more values in list VALID_COURSE, replace the invalid value to None.After finishing the 2 steps, your answer should return a new data dictionary. Computer Science Engineering & Technology Python Programming Share QuestionEmailCopy link Comments (0)