Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want to use the JSON dataset with Python to make a Linear regression for testing whether the violence rate of each county is related

I want to use the JSON dataset with Python to make a Linear regression for testing whether the violence rate of each county is related to the population.

This is my code so far, I don't know how to do next. Panda data frame is not allowed. You may need to download the JSON file: https://catalog.data.gov/dataset/index-violent-property-and-firearm-rates-by-county-beginning-1990/resource/1f3203d2-0eb4-4c9b-8466-6a9b78614253

image text in transcribedimage text in transcribed

Output:

Albany-Population:305810:ViolentRate:332.6 Allegany-Population:45870:ViolentRate:133.0 Bronx-Population:1428772:ViolentRate:920.9 Broome-Population:189538:ViolentRate:327.6 Cattaraugus-Population:74208:ViolentRate:203.5 Cayuga-Population:76385:ViolentRate:199.0 Chautauqua-Population:126417:ViolentRate:241.3 Chemung-Population:83232:ViolentRate:213.9 Chenango-Population:46931:ViolentRate:236.5 Clinton-Population:80080:ViolentRate:159.8 Columbia-Population:59211:ViolentRate:158.8 Cortland-Population:47382:ViolentRate:183.6 Delaware-Population:43120:ViolentRate:194.8 Dutchess-Population:291611:ViolentRate:194.8 Erie-Population:914740:ViolentRate:370.4 Essex-Population:35343:ViolentRate:135.8 Franklin-Population:49852:ViolentRate:136.4 Fulton-Population:52946:ViolentRate:236.1 Genesee-Population:56777:ViolentRate:237.8 Greene-Population:47029:ViolentRate:380.6 Hamilton-Population:4361:ViolentRate:68.8 Herkimer-Population:61174:ViolentRate:232.1 Jefferson-Population:110566:ViolentRate:219.8 Kings-Population:2576770:ViolentRate:550.8 Lewis-Population:26224:ViolentRate:114.4 Livingston-Population:62634:ViolentRate:97.4 Madison-Population:70084:ViolentRate:152.7 Monroe-Population:738135:ViolentRate:290.2 Montgomery-Population:49080:ViolentRate:161.0 Nassau-Population:1352968:ViolentRate:121.3 New York-Population:1624880:ViolentRate:601.8 Niagara-Population:208537:ViolentRate:278.1 Oneida-Population:227680:ViolentRate:281.5 Onondaga-Population:458568:ViolentRate:332.1 Ontario-Population:109474:ViolentRate:151.6 Orange-Population:380924:ViolentRate:186.7 Orleans-Population:40120:ViolentRate:144.6 Oswego-Population:116733:ViolentRate:155.1 Otsego-Population:59117:ViolentRate:167.5 Putnam-Population:98253:ViolentRate:49.9 Queens-Population:2273559:ViolentRate:413.1 Rensselaer-Population:158579:ViolentRate:251.0 Richmond-Population:475062:ViolentRate:273.2 Rockland-Population:325586:ViolentRate:108.7 St Lawrence-Population:106996:ViolentRate:98.1 Saratoga-Population:230182:ViolentRate:87.3 Schenectady-Population:154557:ViolentRate:394.0 Schoharie-Population:30734:ViolentRate:149.7 Schuyler-Population:17763:ViolentRate:56.3 Seneca-Population:33994:ViolentRate:132.4 Steuben-Population:94878:ViolentRate:145.4 Suffolk-Population:1471317:ViolentRate:96.1 Sullivan-Population:74843:ViolentRate:249.9 Tioga-Population:47997:ViolentRate:120.8 Tompkins-Population:102363:ViolentRate:128.0 Ulster-Population:177151:ViolentRate:140.6 Warren-Population:63740:ViolentRate:131.8 Washington-Population:60599:ViolentRate:122.1 Wayne-Population:89121:ViolentRate:184.0 Westchester-Population:964433:ViolentRate:168.5 Wyoming-Population:39619:ViolentRate:116.1 Yates-Population:24639:ViolentRate:93.3
: vith open ('rows.json', 'r', encoding='UTF-8') as json_file: pop_data=json. load (json_file) : print (type (pop_data)) : print(len (pop_data)) 2 for pop_dict in pop_data["data']: if pop_dict [9] = '2019' : country_name pop_dict [8] violent = pop_dict[14] population pop_dict[10] vio = (f (country_name} -Population: {population} :ViolentRate: {violent}') print (vio)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago