Question: Question 4 : fine _ per _ plates ( ) Starting in 2 0 0 4 Michigan moved to issuing plates with the format of

Question 4: fine_per_plates()
Starting in 2004 Michigan moved to issuing plates with the format of ABC1234. That got me thinking, how many vanity plate holders there are in our
dataset? Count for me the number of Michigan vehicles with plates in the following formats that have received a ticket:
ABC1234
ABC123
123ABC
Vanity Plates (i.e. anything other than the aforementioned formats, including missing or NaN values)
Complete the function fine_per_plates() returning a dictionary. The dictinary should be formatted as follows:
platesdict ={ ABC1234: thenumberofvehicles,
ABC123: thenumberofvehicles,
123ABC: thenumberofvehicles
vanity: thenumberofvehicles } code:import pandas as pd
import numpy as np
import re
def fine_per_plates():
plates_dict ={"ABC1234": 0, "ABC123": 0,"123ABC": 0, "vanity": 0}
data = pd.DataFrame({"Plate": ["ABC1234","123","123ABC", "XYZ567", "VANITY"]})
abc1234_pattern = re.compile(r'^[A-Z]{3}\d{4}$')
abc123_pattern = re.compile(r'^[A-Z]{3}\d{3}$')
a123abc_pattern = re.compile(r'^\d{3}[A-Z]{3}$')
for plate in data["Plate"]:
if abc1234_pattern.match(plate):
plates_dict["ABC1234"]+=1
elif abc123_pattern.match(plate):
plates_dict["ABC123"]+=1
elif a123abc_pattern.match(plate):
plates_dict["123ABC"]+=1
else:
plates_dict["vanity"]+=1
return plates_dict
# Test the function
print(fine_per_plates()) the problem is : TypeError Traceback (most recent call last)
Cell In[18], line 1
---->1 assert len(fine_per_plates())==4, "Return a dictionary with four items."
TypeError: fine_per_plates() missing 1 required positional argument: 'data_path'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!