UKHSA-Internal / coronavirus-dashboard-api-python-sdk

Coronavirus (COVID-19) in the UK - API Service SDK for Python
https://coronavirus.data.gov.uk/
MIT License
67 stars 18 forks source link

Structure Change for Deaths #12

Open nimzoking opened 4 years ago

nimzoking commented 4 years ago

Has the structure changed for api calls for information relating to deaths? I keep getting 404 error codes using this structure:

Request failed .... 404 - Not Found Response .......... {"response":"Invalid parameter 'newDeathsByDeathDate' in the requested JSON structure. Did you mean 'newDeaths28DaysByPublishDate'?","status_code":404,"status":"Not Found"}

Tried checking the documentation and there is no mention of this field.

Changing the field to newDeaths28DaysByPublishDate, stopped the python error, but no data was returned.

Have I missed a change announcement somewhere?

Thank you.

xenatisch commented 4 years ago

Release of death figures as ...DeathsByDeathDate has been discontinued.

Re the newDeaths28DaysByPublishDate, could you please share your code here?

grandpamartin commented 4 years ago

I can answer nimzoking’s query having spent some time looking at this particular issue.

The documentation defining the valid list of metrics for the API’s structure was apparently updated on 13th of August 2020 at 17:30pm. In order to find the list, one has to click on the link ‘See a list of valid metrics for structure’ in the Developer’s guide on the Coronavirus dashboard (https://coronavirus.data.gov.uk/developers-guide).

The API documentation on https://publichealthengland.github.io/coronavirus-dashboard-api-python-sdk/pages/examples/general_use.html#structure points to the same Developer’s guide for the metrics.

It is not very helpful that the examples of how to format the Structure on both websites include two metrics are no longer valid; ie "newDeathsByDeathDate" and "cumDeathsByDeathDate".

nimzoking commented 4 years ago

Thank you, I did missed the URL to expand, and was simply concentrating on the examples.

That said, I still get no data returned.

Example Return:

{'data': [{'Date': '2020-08-17', 'areaName': 'Manchester', 'newCasesByPublishDate': 21, 'cumCasesByPublishDate': 3809, 'newDeaths28DaysByPublishDate': None, 'cumDeaths28DaysByPublishDate': None}], 'lastUpdate': '2020-08-17T14:15:27.000000Z', 'length': 1, 'totalPages': 1}

Is None the expected result for the cumulative cases? I am getting a result from cumulative cases, but nothing for cumulative Deaths. Can I safely assume, no deaths in previous 28 days?

Structure I have set up:

cases_and_deaths = { "Date": "date", "areaName": "areaName", "newCasesByPublishDate": "newCasesByPublishDate", "cumCasesByPublishDate": "cumCasesByPublishDate", "newDeaths28DaysByPublishDate": "newDeaths28DaysByPublishDate", "cumDeaths28DaysByPublishDate": "cumDeaths28DaysByPublishDate" }

grandpamartin commented 4 years ago

Hi Carl,

I have just checked with the website to see whether death data is available yet - https://coronavirus.data.gov.uk/deaths?areaType=region https://coronavirus.data.gov.uk/deaths?areaType=region&areaName=North%20West &areaName=North%20West. Unfortunately, it is only available at the Nation level.

I ran the attached script and got data for England, but nothing when I tried the North West region. No point in trying Manchester yet – patience is required!

Regards

Martin

From: Carl Tillotson [mailto:notifications@github.com] Sent: 17 August 2020 21:57 To: publichealthengland/coronavirus-dashboard-api-python-sdk coronavirus-dashboard-api-python-sdk@noreply.github.com Cc: grandpamartin mrh@ravine.plus.com; Comment comment@noreply.github.com Subject: Re: [publichealthengland/coronavirus-dashboard-api-python-sdk] Structure Change for Deaths (#12)

Thank you, I did missed the URL to expand, and was simply concentrating on the examples.

That said, I still get no data returned.

Example Return:

{'data': [{'Date': '2020-08-17', 'areaName': 'Manchester', 'newCasesByPublishDate': 21, 'cumCasesByPublishDate': 3809, 'newDeaths28DaysByPublishDate': None, 'cumDeaths28DaysByPublishDate': None}], 'lastUpdate': '2020-08-17T14:15:27.000000Z', 'length': 1, 'totalPages': 1}

Is None the expected result for the cumulative cases? I am getting a result from cumulative cases, but nothing for cumulative Deaths. Can I safely assume, no deaths in previous 28 days?

Structure I have set up:

cases_and_deaths = { "Date": "date", "areaName": "areaName", "newCasesByPublishDate": "newCasesByPublishDate", "cumCasesByPublishDate": "cumCasesByPublishDate", "newDeaths28DaysByPublishDate": "newDeaths28DaysByPublishDate", "cumDeaths28DaysByPublishDate": "cumDeaths28DaysByPublishDate" }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/publichealthengland/coronavirus-dashboard-api-python-sdk/issues/12#issuecomment-675110556 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUPFW4QFGHPVNQC2FV5WATSBGKQFANCNFSM4P7X53AA . https://github.com/notifications/beacon/AQUPFW3IN5FDL3WLLA7H3XTSBGKQFA5CNFSM4P7X53AKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFA6V5HA.gif

from uk_covid19 import Cov19API

filt = [ 'areaType=nation', 'areaName=England' ]

struct = { "date": "date", "newDeaths28Days":"newDeaths28DaysByPublishDate", "cumDeaths28Days":"cumDeaths28DaysByPublishDate" }

api = Cov19API(filters=filt, structure=struct)

data = api.get_csv(save_as="England deaths_1.csv")

print(data)

xenatisch commented 4 years ago

@nimzoking Yes, it is the expected answer. Cases by PublishDate are only available for nations, not UTLAs or LTLAs.

Try newCasesBySpecimenDate or cumCasesBySpecimenDate instead. You should get the full data then.

We are hoping to unify the cases data and make them available by SpecimenDate soon.

Hope this helps.

grandpamartin commented 4 years ago

Yes, but I only get the data for nations. Nothing for regions which the dashboard says Is also available on the new Deaths page. Try again tomorrow.

Sent from my iPad Martin

On 17 Aug 2020, at 11:03 pm, Pouria Hadjibagheri notifications@github.com wrote:

 Hi @grandpamartin, have you tried using the newDeaths28DaysByPublishDate and cumDeaths28DaysByPublishDate metrics? The previous metrics have been retired and these new ones have been added.

I will update SDK docs as soon as I find a bit of time in my diary. Apologies for the inconvenience.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

xenatisch commented 4 years ago

@grandpamartin Oh you mean the 28-day deaths. Yes, it was only the latest at LA-level today. We are waiting for the data to come through... It'll be pushed to the database and released as soon as we receive it. Our ETL, database, and API infrastructures are set up and ready to go...

grandpamartin commented 4 years ago

I have just checked the Dashboard and found that Daily deaths within 28 days of positive test by date reported are now shown for Nations and Regions. The North West region has the most at 6 new deaths. By a little trial and error using the API I found that Kirklees has 1 newDeaths28DaysByPublishDate. The cumDeaths28DaysByPublishDate column is empty. When I looked at Manchester, 0 is shown for the new deaths and the cumulative column is also empty. Seems to mean that the API is working down to utla level at least. Incidentally, cases are being shown for Nations and below by Specimen Date (as a time series) and for the latest date only by Publish Date as well. It seems that the UK case data is only by Publish Date since Northern Ireland does not submit by Specimen Dates (I think).

xenatisch commented 4 years ago

@grandpamartin cumDeaths28DaysByPublishDate is indeed empty. We're working on it. We added a bunch of new metrics today again... do have a look.

The API is working regardless of level, it's just that we don't have the data at all levels yet.

We don't have all the metrics for every region. This is primarily because different DAs/LAs have been producing different metrics. We are working to standardise them and make at least one metric available for everything... but it takes some time.