create two data lists from a json file, however; I keep getting 'TypeError: string indices must...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
create two data lists from a json file, however; I keep getting 'TypeError: string indices must be integers'. I need to have the date in one variable and the count in another to generate a line graph. here is the code I have so far: #import libraries import requests import pandas as pd import matplotlib.pyplot as pyt #retrieve data from URL search_url = "https://data.europa.eu/api/hub/statistics/data/num-datasets' response requests.get (search_url) root response.json() print (root) #data set for graph x = [i['date'] for i in root] y = [i['count'] for i in root] print(x) print(y) TypeError: string indices must be integers¹ How do I generate a data set out of the json file without throwing this error? create two data lists from a json file, however; I keep getting 'TypeError: string indices must be integers'. I need to have the date in one variable and the count in another to generate a line graph. here is the code I have so far: #import libraries import requests import pandas as pd import matplotlib.pyplot as pyt #retrieve data from URL search_url = "https://data.europa.eu/api/hub/statistics/data/num-datasets' response requests.get (search_url) root response.json() print (root) #data set for graph x = [i['date'] for i in root] y = [i['count'] for i in root] print(x) print(y) TypeError: string indices must be integers¹ How do I generate a data set out of the json file without throwing this error?
Expert Answer:
Answer rating: 100% (QA)
It looks like you have a few issues in your code You cant use string indices for a list directly and ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
The intelligence community has found that the adversary is developing a capability that would be available six years from now. The current U.S. system doesn't have the ability to address the new...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
You have been employed to create program to assist the manager of a coffee shop. You decide to make a prototype application in Java to show what you can do, and to be able to ask the manager what...
-
A closed tank contains oil with a specific gravity 0.85. If the gauge pressure at a point 10 feet below the oil surface is 23. 7 psi (lb/in.2), determine the absolute pressure and gauge pressure (in...
-
Determine the rate of change HG of the angular momentum HG of the rectangular frame of Prob.18.1. 300 600 R G
-
Risk Analysis and Management of Construction and Operations in Offshore Wind Power Project Abstract: Many countries have increased the use of renewable energy and strongly promoted offshore wind...
-
What issues might arise during and as a result of the implementation of HRIS T&D applications?
-
The Mary Ellen Hospice provides services for terminally.ill patients and their families. The hospice provides an accommodation unit for up to six patients and a support service for outpatients, in...
-
What happens when spectrometer gives negative values? Why?
-
Conrad Manufacturing is preparing its master budget for the first quarter of the upcoming year. The following data pertain to Conrad Manufacturing's operations: Current assets as of December 31...
-
Corrine sold her home a few years ago in a seller financed transaction. She qualifies for the principle residence exclusion at the time of sale and she was able to exclude the entire amount of her...
-
(4) Tim, the manager of Tiger Investment Fund Co, is attempting to evaluate two possible portfolios, which consist of the same four assets held in different proportions. He is particularly interested...
-
A paper machine makes frequent weight changes. The production management feels that the stock flow can be safely moved at a maximum rate of 50 gpm per minute. Before trying this on the machine they...
-
According to Larry Swedroe (in his talk & in his book), why might an investor expect investments in companies with high ESG scores ("green companies") to underperform investments in companies with...
-
B2 ) Consider the following information on a portfolio of three stocks: State of Economy Probability of State of Economy Boom .15 Stock A Rate of Return .05 Stock B. Rate of Return 21 Stock C Rate of...
-
14. Consider the following information on three stocks: Probability of State Rate of Return if State Occurs State of Economy of Economy Stock A Stock B Stock C Boom 0.45 0.55 0.35 0.65 Normal 0.50...
-
Classify each phrase as a description of alpha helices, beta sheets, beta turns, or all. a Helices successive R groups point in opposite directions Sheets Answer Bank Turns all -NH groups point in...
-
On July 1, 2011, Flashlight Corporation sold equipment it had recently purchased to an unaffiliated company for $480,000. The equipment had a book value on Flashlights books of $390,000 and a...
-
Jason and Mary are married taxpayers in 2012. They are both under age 65 and in good health. For this tax year, they have a total of $41,000 in wages and $500 in interest income. Jason and Mary's...
-
In the 2012 tax year, Michelle paid the following amounts relating to her 2010 tax return: Tax deficiency..........................................$5,000 Negligence...
-
Brian and Kim have a 12-year-old child, Stan. For 2012, Brian and Kim have taxable income of $52,000, and Stan has nonqualifying dividend income of $4,500 and investment expenses of $250. No election...
-
A single stage single acting air compressor has intake pressure 1 bar and delivery pressure 10 bar. The compression and expansion follow the law \(\mathrm{pV}^{1.3}=\) constant. The piston speed and...
-
Find the expression for volumetric efficiency of the reciprocating compressor.
-
An air compressor has eight stages of an equal pressure ratio of 1.4. The flow rate through the compressor and the overall efficiency are 40 \(\mathrm{kg} / \mathrm{sec}\) and \(92 \%\),...
Study smarter with the SolutionInn App