Skip to content

Instantly share code, notes, and snippets.

@hynek2001
Created December 20, 2021 23:59
Show Gist options
  • Save hynek2001/16b5610c46cdc059e7216e20970c7b14 to your computer and use it in GitHub Desktop.
Save hynek2001/16b5610c46cdc059e7216e20970c7b14 to your computer and use it in GitHub Desktop.
kjn
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### zdroje dat, obecne info\n",
"\n",
"#### covid 19 CZ\n",
"https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19\n",
"od listopadu presli na openapi v3, ktere vyzaduje token a registraci. max 1000/h\n",
"\n",
"udelal jsem si ucet na https://onemocneni-aktualne.mzcr.cz/api/v3/docs a token pro [email protected] je c08b3a92601ff817a79af9fd6e625bf2"
]
},
{
"cell_type": "code",
"execution_count": 1,
"outputs": [
{
"data": {
"text/plain": " @id \\\n0 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/3c1... \n1 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/2e6... \n2 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/89d... \n3 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/26c... \n4 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/141... \n.. ... \n95 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/15d... \n96 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/890... \n97 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/5d0... \n98 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/ccd... \n99 /api/v3/kraj-okres-nakazeni-vyleceni-umrti/c33... \n\n @type id \\\n0 kraj-okres-nakazeni-vyleceni-umrti 3c143ed4-2795-4859-bbff-7b7a985afe55 \n1 kraj-okres-nakazeni-vyleceni-umrti 2e6ce62a-c84a-46d5-a4f3-d165e9a61446 \n2 kraj-okres-nakazeni-vyleceni-umrti 89d3a2d2-7bf4-408d-abb6-0b14551a9977 \n3 kraj-okres-nakazeni-vyleceni-umrti 26c94b5b-7684-4e60-8b24-ff24ce009d62 \n4 kraj-okres-nakazeni-vyleceni-umrti 14199628-3bad-4817-bc89-ee70762abf46 \n.. ... ... \n95 kraj-okres-nakazeni-vyleceni-umrti 15d2b69b-8cc3-4553-ae19-475a90368d4f \n96 kraj-okres-nakazeni-vyleceni-umrti 8905b8cd-f936-4f21-b6c2-74fc0f4482af \n97 kraj-okres-nakazeni-vyleceni-umrti 5d044f6c-198e-4e72-9952-0955fbe97bdd \n98 kraj-okres-nakazeni-vyleceni-umrti ccd79c85-0a36-40ed-b188-48869bffa932 \n99 kraj-okres-nakazeni-vyleceni-umrti c33ccd3e-0915-405f-8ea6-f1a38bdf698e \n\n datum kraj_nuts_kod okres_lau_kod kumulativni_pocet_nakazenych \\\n0 2020-03-25 CZ041 CZ0412 18 \n1 2020-03-25 CZ041 CZ0413 6 \n2 2020-03-25 CZ042 CZ0421 21 \n3 2020-03-25 CZ042 CZ0422 3 \n4 2020-03-25 CZ042 CZ0423 11 \n.. ... ... ... ... \n95 2020-03-26 CZ052 CZ0525 6 \n96 2020-03-26 CZ053 CZ0531 21 \n97 2020-03-26 CZ053 CZ0532 16 \n98 2020-03-26 CZ053 CZ0533 9 \n99 2020-03-26 CZ053 CZ0534 12 \n\n kumulativni_pocet_vylecenych kumulativni_pocet_umrti \n0 0 0 \n1 0 0 \n2 4 0 \n3 0 0 \n4 0 0 \n.. ... ... \n95 0 0 \n96 1 0 \n97 0 1 \n98 0 0 \n99 0 0 \n\n[100 rows x 9 columns]",
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>@id</th>\n <th>@type</th>\n <th>id</th>\n <th>datum</th>\n <th>kraj_nuts_kod</th>\n <th>okres_lau_kod</th>\n <th>kumulativni_pocet_nakazenych</th>\n <th>kumulativni_pocet_vylecenych</th>\n <th>kumulativni_pocet_umrti</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/3c1...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>3c143ed4-2795-4859-bbff-7b7a985afe55</td>\n <td>2020-03-25</td>\n <td>CZ041</td>\n <td>CZ0412</td>\n <td>18</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>1</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/2e6...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>2e6ce62a-c84a-46d5-a4f3-d165e9a61446</td>\n <td>2020-03-25</td>\n <td>CZ041</td>\n <td>CZ0413</td>\n <td>6</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>2</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/89d...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>89d3a2d2-7bf4-408d-abb6-0b14551a9977</td>\n <td>2020-03-25</td>\n <td>CZ042</td>\n <td>CZ0421</td>\n <td>21</td>\n <td>4</td>\n <td>0</td>\n </tr>\n <tr>\n <th>3</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/26c...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>26c94b5b-7684-4e60-8b24-ff24ce009d62</td>\n <td>2020-03-25</td>\n <td>CZ042</td>\n <td>CZ0422</td>\n <td>3</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>4</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/141...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>14199628-3bad-4817-bc89-ee70762abf46</td>\n <td>2020-03-25</td>\n <td>CZ042</td>\n <td>CZ0423</td>\n <td>11</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>...</th>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n </tr>\n <tr>\n <th>95</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/15d...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>15d2b69b-8cc3-4553-ae19-475a90368d4f</td>\n <td>2020-03-26</td>\n <td>CZ052</td>\n <td>CZ0525</td>\n <td>6</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>96</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/890...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>8905b8cd-f936-4f21-b6c2-74fc0f4482af</td>\n <td>2020-03-26</td>\n <td>CZ053</td>\n <td>CZ0531</td>\n <td>21</td>\n <td>1</td>\n <td>0</td>\n </tr>\n <tr>\n <th>97</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/5d0...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>5d044f6c-198e-4e72-9952-0955fbe97bdd</td>\n <td>2020-03-26</td>\n <td>CZ053</td>\n <td>CZ0532</td>\n <td>16</td>\n <td>0</td>\n <td>1</td>\n </tr>\n <tr>\n <th>98</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/ccd...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>ccd79c85-0a36-40ed-b188-48869bffa932</td>\n <td>2020-03-26</td>\n <td>CZ053</td>\n <td>CZ0533</td>\n <td>9</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>99</th>\n <td>/api/v3/kraj-okres-nakazeni-vyleceni-umrti/c33...</td>\n <td>kraj-okres-nakazeni-vyleceni-umrti</td>\n <td>c33ccd3e-0915-405f-8ea6-f1a38bdf698e</td>\n <td>2020-03-26</td>\n <td>CZ053</td>\n <td>CZ0534</td>\n <td>12</td>\n <td>0</td>\n <td>0</td>\n </tr>\n </tbody>\n</table>\n<p>100 rows × 9 columns</p>\n</div>"
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"import json\n",
"import pprint\n",
"import pandas as pd\n",
"\n",
"token = \"c08b3a92601ff817a79af9fd6e625bf2\"\n",
"apiUrl= \"https://onemocneni-aktualne.mzcr.cz/api/v3/\"\n",
"set = \"kraj-okres-nakazeni-vyleceni-umrti\"\n",
"page = 20\n",
"\n",
"\n",
"re = requests.get(url=apiUrl+set,\n",
" params={\n",
" \"page\":str(page),\n",
" \"apiToken\":token\n",
" })\n",
"je = json.loads(re.text)\n",
"df = pd.DataFrame(je[\"hydra:member\"])\n",
"df\n"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment