Skip to content

Instantly share code, notes, and snippets.

@larsyencken
Last active June 26, 2023 23:32
Show Gist options
  • Save larsyencken/5c9aedaaacba4f593d1b18d797cc2c00 to your computer and use it in GitHub Desktop.
Save larsyencken/5c9aedaaacba4f593d1b18d797cc2c00 to your computer and use it in GitHub Desktop.
OWID: plain vs rich catalog display
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "d45f090b-9971-4435-9b45-193c70ec1f50",
"metadata": {},
"source": [
"# Plain display of catalog objects"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "febfb1bb-45d9-408f-a0b5-26b272480a64",
"metadata": {},
"outputs": [],
"source": [
"t = catalog.find_one('gbd_prevalence')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "36e2e30b-6051-4414-a481-972ce39f4c7e",
"metadata": {},
"outputs": [
{
"data": {
"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></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>incidence__number</th>\n",
" <th>prevalence__number</th>\n",
" <th>incidence__rate</th>\n",
" <th>prevalence__rate</th>\n",
" <th>incidence__share_of_the_population</th>\n",
" <th>prevalence__share_of_the_population</th>\n",
" </tr>\n",
" <tr>\n",
" <th>country</th>\n",
" <th>year</th>\n",
" <th>sex</th>\n",
" <th>age</th>\n",
" <th>cause</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">Afghanistan</th>\n",
" <th rowspan=\"5\" valign=\"top\">1990</th>\n",
" <th rowspan=\"5\" valign=\"top\">Both</th>\n",
" <th rowspan=\"5\" valign=\"top\">70+ years</th>\n",
" <th>Acne vulgaris</th>\n",
" <td>197.17</td>\n",
" <td>399.30</td>\n",
" <td>60.19</td>\n",
" <td>121.89</td>\n",
" <td>6.02e-02</td>\n",
" <td>1.22e-01</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Acute glomerulonephritis</th>\n",
" <td>22.85</td>\n",
" <td>1.28</td>\n",
" <td>6.98</td>\n",
" <td>0.39</td>\n",
" <td>6.98e-03</td>\n",
" <td>3.91e-04</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Acute hepatitis</th>\n",
" <td>4924.06</td>\n",
" <td>554.64</td>\n",
" <td>1503.18</td>\n",
" <td>169.31</td>\n",
" <td>1.50e+00</td>\n",
" <td>1.69e-01</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Acute hepatitis A</th>\n",
" <td>1.41</td>\n",
" <td>0.11</td>\n",
" <td>0.43</td>\n",
" <td>0.03</td>\n",
" <td>4.29e-04</td>\n",
" <td>3.30e-05</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Acute hepatitis B</th>\n",
" <td>3304.66</td>\n",
" <td>381.31</td>\n",
" <td>1008.82</td>\n",
" <td>116.40</td>\n",
" <td>1.01e+00</td>\n",
" <td>1.16e-01</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" incidence__number \\\n",
"country year sex age cause \n",
"Afghanistan 1990 Both 70+ years Acne vulgaris 197.17 \n",
" Acute glomerulonephritis 22.85 \n",
" Acute hepatitis 4924.06 \n",
" Acute hepatitis A 1.41 \n",
" Acute hepatitis B 3304.66 \n",
"\n",
" prevalence__number \\\n",
"country year sex age cause \n",
"Afghanistan 1990 Both 70+ years Acne vulgaris 399.30 \n",
" Acute glomerulonephritis 1.28 \n",
" Acute hepatitis 554.64 \n",
" Acute hepatitis A 0.11 \n",
" Acute hepatitis B 381.31 \n",
"\n",
" incidence__rate \\\n",
"country year sex age cause \n",
"Afghanistan 1990 Both 70+ years Acne vulgaris 60.19 \n",
" Acute glomerulonephritis 6.98 \n",
" Acute hepatitis 1503.18 \n",
" Acute hepatitis A 0.43 \n",
" Acute hepatitis B 1008.82 \n",
"\n",
" prevalence__rate \\\n",
"country year sex age cause \n",
"Afghanistan 1990 Both 70+ years Acne vulgaris 121.89 \n",
" Acute glomerulonephritis 0.39 \n",
" Acute hepatitis 169.31 \n",
" Acute hepatitis A 0.03 \n",
" Acute hepatitis B 116.40 \n",
"\n",
" incidence__share_of_the_population \\\n",
"country year sex age cause \n",
"Afghanistan 1990 Both 70+ years Acne vulgaris 6.02e-02 \n",
" Acute glomerulonephritis 6.98e-03 \n",
" Acute hepatitis 1.50e+00 \n",
" Acute hepatitis A 4.29e-04 \n",
" Acute hepatitis B 1.01e+00 \n",
"\n",
" prevalence__share_of_the_population \n",
"country year sex age cause \n",
"Afghanistan 1990 Both 70+ years Acne vulgaris 1.22e-01 \n",
" Acute glomerulonephritis 3.91e-04 \n",
" Acute hepatitis 1.69e-01 \n",
" Acute hepatitis A 3.30e-05 \n",
" Acute hepatitis B 1.16e-01 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t.head()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "3cddec38-97e2-4eeb-a56f-4eb7f212a927",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"TableMeta(short_name='gbd_prevalence', title='Institute for Health Metrics and Evaluation - Global Burden of Disease (2019) - Prevalence and incidence - Prevalence and incidence', description='Prevalence and incidence', dataset=DatasetMeta(channel='garden', namespace='ihme_gbd', short_name='gbd_prevalence', title='Institute for Health Metrics and Evaluation - Global Burden of Disease (2019) - Prevalence and incidence - Prevalence and incidence', description='The Global Burden of Disease (GBD) provides a comprehensive picture of mortality and disability across countries, time, age, and sex. It quantifies health loss from hundreds of diseases, injuries, and risk factors, so that health systems can be improved and disparities eliminated.\\n\\nGBD research incorporates both the prevalence of a given disease or risk factor and the relative harm it causes. With these tools, decision-makers can compare different health issues and their effects.\\n\\nThis dataset contains metrics on the prevalence and incidence of diseases and injuries.\\n', sources=[Source(name='Global Burden of Disease Study (2019) - Prevalence and Incidence', description=None, url=None, source_data_url=None, owid_data_url=None, date_accessed=None, publication_date=None, publication_year=None, published_by='Institute of Health Metrics and Evaluation', publisher_source=None)], licenses=[License(name=None, url='https://www.healthdata.org/data-tools-practices/data-practices/terms-and-conditions')], is_public=True, additional_info=None, version='2019', source_checksum='526835326d5840d6856b1adffcf44675'), primary_key=['country', 'year', 'sex', 'age', 'cause'])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t.metadata"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "2baedda0-5b93-4e85-93a9-aa095324acce",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"country year sex age cause \n",
"Afghanistan 1990 Both 70+ years Acne vulgaris 197.17\n",
" Acute glomerulonephritis 22.85\n",
" Acute hepatitis 4924.06\n",
" Acute hepatitis A 1.41\n",
" Acute hepatitis B 3304.66\n",
" ... \n",
"Zimbabwe 2019 Both Age-standardized Visceral leishmaniasis NaN\n",
" Vitamin A deficiency NaN\n",
" Whooping cough NaN\n",
" Yellow fever NaN\n",
" Zika virus NaN\n",
"Name: incidence__number, Length: 16769130, dtype: float32"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t[t.columns[0]]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "6c138d43-01ea-4d96-b98a-082d6251a380",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"VariableMeta(title='Number of new cases per year', description=None, sources=[], licenses=[], unit='new cases per year', short_unit=None, display={'numDecimalPlaces': 0}, additional_info=None)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t[t.columns[0]].metadata"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment