subject

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'}]

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 20:40
Convert and simplify the following sentences to conjunctive normal form (cnf): (a) (p → (q → r)) → (p → (r → q)) (b) (p ∧ q) → (¬p ↔ q) (c) ((p → q) ∧ ¬q) → ¬p
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
Column a of irma’s spreadsheet contains titles for each row, but her document is too big and will be printed three pages across. she wants to be sure that every page will be understood. what can irma do to with this problem?
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
What would be the address of the cell, which is at the intersection of the second row and the third column in a worksheet?
Answers: 1
You know the right answer?
Two functions require that each function process the dictionaries' dates. These dates are the values...
Questions
question
Mathematics, 14.04.2020 17:37
Questions on the website: 13722363