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 '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
It looks like you have a few issues in your code You cant use string indices for a list directly and ... View full answer
Get step-by-step solutions from verified subject matter experts
