Question: Reducing the Data Load the contents of the JSON - formatted data file into a variable named city _ dicts _ Ist To create the

Reducing the Data
Load the contents of the JSON-formatted data file into a variable named city_dicts_Ist
To create the data structures required to produce the three bar charts you will need to reduce city_dicts_Ist into three summary dictionaries:
murder_by_region
violent_by_region
nonviolent_by_region
To do so, iterate over city_dicts_Ist and create each respective dictionary using an accumulation pattern. The resulting dictionaries should be identical to this:
1 print(murder_by_region)
2 print(violent_by_region)
3 print(nonviolent_by_region)
'South': 5018, 'West': 2605, 'Northeast': 1674, 'Midwest': 3304)
{{'South': 331011, 'West': 259401, 'Northeast: 156891, 'Midwest': 211854)('South': 2080097, 'West': 1781665, 'Northeast': 760200, 'Midwest': 1226462)
Create a function named accum_crime() to make the three dictionaries shown above.
accum crime () has three parameters:
Parameter
Description
unit
key upon which to accumulate (i.e. Region or State)
crime
crime (e.g. Murder, Vehicle_Theft, etc.) used to accumulate summary values for the specified unit
city_dicts_lst
list containing dictionaries for each city, read from provided data
file
The accum_crime () function should produce the summary dictionaries shown above when appropriate parameters are provided.

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 Finance Questions!