Question: create two data lists from a json file, however; I keep getting 'TypeError: string indices must be integers'. I need to have the date

create two data lists from a json file, however; I keep getting

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?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It looks like you have a few issues in your code You cant use string indices for a list directly and ... View full answer

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