I am working to create a custom COVID dataframe. I would like to return only specific parameters. The below is my code.
import requests
params = {'Date','Deaths'}
resp = requests.get('https://api.covid19api.com/country/canada', params=params)
jsonResponse = resp.json()
print(jsonResponse)
The result I expect would be just the date and death information, for all available dates.
However, it returns the error 'too many values to unpack (expected 2)'.
Would you please suggest how I might get the desired response?
Edit: I'm not looking for the instance of a specific key value pair (eg when Deaths = 27, which I understand would be coded as params = {'Deaths':'27'}
. Rather, I only want to extract the date and deaths keys, with all associated values to get the following:
2020-03-22T00:00:00Z, 20
2020-03-23T00:00:00Z, 27
2020-03-24T00:00:00Z, 31...
Is there a way to specify this when the API is called, or do I need to retrieve all information in the API first, and then filter for 'Date' and 'Deaths'?
Thanks in advance!
you have to define params as {"key": "value"}.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.