Computers and Technology

Two functions require that each function process the dictionaries' dates. These dates are the values associated with the key 'tow_date'. The dates are stored as strings and use a fixed-position format. This format makes finding information easy. For example, if a variable val was assigned to a value associated with the key 'tow_date', we can get the month and date using:

month = int(val[5]+val[6]) # Concatenates & converts month's digits

day = int(val[8]+val[9]) # Concatenates & converts days's digits

count_by_month

Define a function named count_by_month with one parameter. This parameter will be a list of dictionaries (the data). This function must return a list with a length of 12 containing the number of dictionaries with that 'tow_date' month. Remember to adjust for how we use lists (for example, January is month 1 but its count is the list's entry at index 0). You SHOULD assume that all dictionaries in the parameter will have 'tow_date'as a key.

Sample function call: count_by_month(data)

count_by_day

Define a function named count_by_day with one parameter. This parameter will be a list of dictionaries (the data). This function must return a list with a length of 31 containing the number of dictionaries with that 'tow_date' day. Remember to adjust for how we use lists (for example, the first day of each month is day 1 but its count is the list's entry at index 0). You SHOULD assume that all dictionaries in the parameter will have 'tow_date'as a key.

Sample function call: count_by_day(data)

DATA IS DEFINED BELOW

data = [ {'unique_key': '201209064DPE', 'tow_date': '2012-09-06T00:00:00.000', 'agency': 'DPE', 'vehicle_year': 0, 'vehicle_make': 'MINI', 'tow_location': 'MAIN/CUSTER', 'city': 'Buffalo', 'state': 'NY', 'zip': '14214', 'tow_reason': 'AI', 'tow_description': 'ACCIDENT', 'location_1': "{'latitude': '42.950029001582', 'longitude': '-78.827175001441'}", 'latitude': 42.95002900158201, 'longitude': -78.827175001441, 'council_district': 'UNIVERSITY', 'police_district': 'District E', 'census_tract': '47', 'census_block_group': '5', 'census_block': '5003', 'neighborhood': 'UNKNOWN'},

{'unique_key': '200801247RON', 'tow_date': '2008-01-24T00:00:00.000', 'agency': 'RON', 'vehicle_year': 1995, 'vehicle_make': 'CHEV', 'license_state': 'NY', 'tow_location': '191 14TH', 'city': 'Buffalo', 'state': 'NY', 'zip': '14213', 'tow_reason': 'IP', 'tow_description': 'ILLEGALLY PARKED', 'location_1': "{'latitude': '42.906118854478', 'longitude': '-78.886454771174'}", 'latitude': 42.90611885447759, 'longitude': -78.88645477117358, 'council_district': 'NIAGARA', 'police_district': 'District B', 'census_tract': '69.02', 'census_block_group': '1', 'census_block': '1004', 'neighborhood': 'UNKNOWN'},

{'unique_key': '201308292RIV', 'tow_date': '2013-08-29T00:00:00.000', 'agency': 'RIV', 'vehicle_year': 2000, 'vehicle_make': 'BUIC', 'license_state': 'NY', 'tow_location': '98 GREENWOOD', 'city': 'Buffalo', 'state': 'NY', 'zip': '14213', 'tow_reason': 'IP', 'tow_description': 'ILLEGALLY PARKED', 'location_1': "{'latitude': '42.92264365562', 'longitude': '-78.888887800432'}", 'latitude': 42.922643655619744, 'longitude': -78.88888780043183, 'council_district': 'NIAGARA', 'police_district': 'District D', 'census_tract': '171', 'census_block_group': '3', 'census_block': '3004', 'neighborhood': 'UNKNOWN'},

{'unique_key': '2010040512DPE', 'tow_date': '2010-04-05T00:00:00.000', 'agency': 'DPE', 'vehicle_year': 1998, 'vehicle_make': 'CHEV', 'license_state': 'NY', 'tow_location': 'SMITH/CLINTON', 'city': 'Buffalo', 'state': 'NY', 'zip': '14210', 'tow_reason': 'IL', 'tow_description': 'ILLEGAL VEHICLE', 'location_1': "{'latitude': '42.880136970577', 'longitude': '-78.844075992214'}", 'latitude': 42.88013697057658, 'longitude': -78.84407599221383, 'council_district': 'FILLMORE', 'police_district': 'District C', 'census_tract': '15', 'census_block_group': '1', 'census_block': '1029', 'neighborhood': 'UNKNOWN'}]

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, richellemjordan
Draw the hierarchy chart and design the logic for a program that calculates service charges for hazel's housecleaning service. the program contains housekeeping, detail loop, and end-of-job modules. the main program declares any needed global variables and constants and calls the other modules. the housekeeping module displays a prompt for and accepts a customer's last name. while the user does not enter for the name, the detail loop accepts the number of bathrooms and the number of other rooms to be cleaned. the service charge is computed as $40 plus $15 for each bathroom and $10 for each of the other rooms. the detail loop also displays the service charge and then prompts the user for the next customer's name. the end-of-job module, which executes after the user enters the sentinel value for the name, displays a message that indicates the program is complete.
Answers: 2
image
Computers and Technology, 22.06.2019 08:00, wgdelgado
What is the first step in creating a maintenance ?
Answers: 2
image
Computers and Technology, 22.06.2019 15:30, mariap3504
Whats are the different parts of no verbal comunication, especially body language?
Answers: 3
image
Computers and Technology, 22.06.2019 16:00, eden1017
Why should characters such as / \ " ' * ; - ? [ ] ( ) ~ ! $ { } < > # @ & | space, tab, and newline be avoided in file names?
Answers: 2
Do you know the correct answer?
Two functions require that each function process the dictionaries' dates. These dates are the values...

Questions in other subjects: