{"id":17302514,"url":"https://github.com/azulgarza/covidmx","last_synced_at":"2025-12-13T14:39:57.143Z","repository":{"id":62565108,"uuid":"255164244","full_name":"AzulGarza/covidmx","owner":"AzulGarza","description":"Python API to get information about COVID-19 in México.","archived":false,"fork":false,"pushed_at":"2023-05-22T22:18:18.000Z","size":658,"stargazers_count":18,"open_issues_count":6,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-24T13:28:10.670Z","etag":null,"topics":["api","coronavirus","covid-19","mexico","mexico-maps","pip","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AzulGarza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-04-12T20:27:41.000Z","updated_at":"2021-10-14T17:58:33.000Z","dependencies_parsed_at":"2022-11-03T16:15:21.212Z","dependency_job_id":"2a95a772-8e71-41e5-a619-51b75c8b8fb4","html_url":"https://github.com/AzulGarza/covidmx","commit_stats":{"total_commits":98,"total_committers":3,"mean_commits":"32.666666666666664","dds":"0.10204081632653061","last_synced_commit":"94009e8570e766a33869e6ecda2bd1114fb7a598"},"previous_names":["azulgarza/covidmx","federicogarza/covidmx"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzulGarza%2Fcovidmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzulGarza%2Fcovidmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzulGarza%2Fcovidmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzulGarza%2Fcovidmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AzulGarza","download_url":"https://codeload.github.com/AzulGarza/covidmx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245149233,"owners_count":20568853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","coronavirus","covid-19","mexico","mexico-maps","pip","python"],"created_at":"2024-10-15T11:47:47.430Z","updated_at":"2025-12-13T14:39:52.086Z","avatar_url":"https://github.com/AzulGarza.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build](https://github.com/FedericoGarza/covidmx/workflows/Python%20package/badge.svg?branch=master)](https://github.com/FedericoGarza/covidmx/tree/master)\n[![PyPI version fury.io](https://badge.fury.io/py/covidmx.svg)](https://pypi.python.org/pypi/covidmx/)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3758590.svg)](https://doi.org/10.5281/zenodo.3758590)\n[![Downloads](https://pepy.tech/badge/covidmx)](https://pepy.tech/project/covidmx)\n[![Python 3.5+](https://img.shields.io/badge/python-3.5+-blue.svg)](https://www.python.org/downloads/release/python-350+/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/FedericoGarza/covidmx/blob/master/LICENSE)\n\n# covidmx\nPython API to get information about COVID-19 in México.\n\n# Requirements\n\n```\nmore-itertools\u003e=6.0.0\npandas\u003e=0.25.2\nUnidecode\u003e=1.1.1\nrequests==2.21.0\nxlrd==1.2.0\nmapsmx==0.0.3\nmatplotlib==3.0.3\nmapclassify==2.2.0\ndescartes==1.1.0\n```\n\n# How to install\n\n```\npip install covidmx\n```\n\n# How to use\n\n## Dirección General de Epidemiología\n\nThe mexican *Dirección General de Epidemiología* [has released open data](https://www.gob.mx/salud/documentos/datos-abiertos-152127) about COVID-19 in México. This source contains information at the individual level such as gender, municipality and health status (smoker, obesity, etc). The package `covidmx` now can handle this source as default. Some variables are encoded as integers and the source also includes a data dictionary with all relevant information. When you pass `clean=True` (default option) returns the decoded data. You can also have access to the catalogue using `return_catalogo=True` and to the description of each one of the variables with `return_descripcion=True`. When you use some of this parameters, the API returns a tuple.\n\n```python\nfrom covidmx import CovidMX\n\ncovid_dge_data = CovidMX().get_data()\nraw_dge_data = CovidMX(clean=False).get_data()\ncovid_dge_data, catalogo_data = CovidMX(return_catalogo=True).get_data()\ncovid_dge_data, descripcion_data = CovidMX(return_descripcion=True).get_data()\ncovid_dge_data, catalogo_data, descripcion_data = CovidMX(return_catalogo=True, return_descripcion=True).get_data()\n```\n\nTo get historical data use:\n\n```python\ncovid_dge_data = CovidMX(date='12-04-2020').get_data()\n```\n\nDefault date format is `%d-%m-%Y`, but you can also use a particular format with:\n\n\n```python\ncovid_dge_data = CovidMX(date='2020-04-12', date_format='%Y-%m-%d').get_data()\n```\n\n### Plot module\n\nAs of version 0.3.0, `covidmx` includes a module to create maps of different COVID-19 status at the national and state levels, with the possibility of including municipalities (using information of the *Dirección General de Epidemiologia*).\n\n```python\nfrom covidmx import CovidMX\n\ndge_plot = CovidMX().get_plot()\n```\n\nYou can check available status and available states using:\n\n```python\ndge_plot.available_states\n\narray(['MÉXICO', 'CIUDAD DE MÉXICO', 'TAMAULIPAS', 'BAJA CALIFORNIA',\n       'YUCATÁN', 'GUERRERO', 'BAJA CALIFORNIA SUR', 'JALISCO',\n       'NUEVO LEÓN', 'SONORA', 'VERACRUZ DE IGNACIO DE LA LLAVE',\n       'PUEBLA', 'CAMPECHE', 'GUANAJUATO', 'SAN LUIS POTOSÍ',\n       'MICHOACÁN DE OCAMPO', 'COAHUILA DE ZARAGOZA', 'QUERÉTARO',\n       'AGUASCALIENTES', 'TABASCO', 'HIDALGO', 'ZACATECAS', 'DURANGO',\n       'CHIHUAHUA', 'CHIAPAS', 'SINALOA', 'QUINTANA ROO', 'MORELOS',\n       'TLAXCALA', 'NAYARIT', 'OAXACA', 'COLIMA'], dtype=object)\n```\n\n```python\ndge_plot.available_status\n\n['confirmados', 'negativos', 'sospechosos', 'muertos']\n```\n\nTo plot a national map just use:\n\n```python\ndge_plot.plot_map(status='confirmados')\n```\n\n\u003cimg src=https://raw.githubusercontent.com/FedericoGarza/covidmx/dev/.github/images/confirmados-nacional.png width=400\u003e\n\n\nIf you want to include municipalities use:\n\n```python\ndge_plot.plot_map(status='confirmados', add_municipalities=True)\n```\n\u003cimg src=https://raw.githubusercontent.com/FedericoGarza/covidmx/dev/.github/images/confirmados-nacional-muns.png width=400\u003e\n\n\nYou can pass a particular state filling the `state` argument with a valid name included in the `available_states` attribute:\n\n```python\ndge_plot.plot_map(status='confirmados', state='CIUDAD DE MÉXICO', add_municipalities=True)\n```\n\n|`state='CIUDAD DE MÉXICO'`| `state='JALISCO'`| `state='MORELOS'`| `state='MÉXICO'`|\n|:------------------------:|:----------------:|:----------------:|:---------------:|\n|\u003cimg src=https://raw.githubusercontent.com/FedericoGarza/covidmx/dev/.github/images/confirmados-CIUDAD%20DE%20M%C3%89XICO-muns.png width=\"220\"\u003e| \u003cimg src=https://raw.githubusercontent.com/FedericoGarza/covidmx/dev/.github/images/confirmados-JALISCO-muns.png width=\"220\"\u003e | \u003cimg src=https://raw.githubusercontent.com/FedericoGarza/covidmx/dev/.github/images/confirmados-MORELOS-muns.png width=\"220\"\u003e| \u003cimg src=https://raw.githubusercontent.com/FedericoGarza/covidmx/dev/.github/images/confirmados-MÉXICO-muns.png width=\"220\"\u003e|\n\n\nFinally you can plot another interest variable (according to `available_status` attribute):\n\n```python\ndge_plot.plot_map(status='sospechosos', add_municipalities=True)\n```\n\u003cimg src=https://raw.githubusercontent.com/FedericoGarza/covidmx/dev/.github/images/sospechosos-nacional.png width=400\u003e\n\nYou can save your maps using `save_file_name`:\n\n```python\ndge_plot.plot_map(status='sospechosos', add_municipalities=True, save_file_name='sospechosos-nacional.png')\n```\n\n## Serendipia\n\nSerendipia [publishes daily information](https://serendipia.digital/2020/03/datos-abiertos-sobre-casos-de-coronavirus-covid-19-en-mexico/) of the mexican *Secretaría de Salud* about covid in open format (.csv). This api downloads this data easily, making it useful for task automation.\n\n```python\nfrom covidmx import CovidMX\n\nlatest_published_data = CovidMX(source='Serendipia').get_data()\n```\n\nThen `CovidMX` instances a `Serendipia` class, searches the latest published data for both confirmed and suspects individuals and finally clean the data. Nevertheless, a more specific search can be conducted (see docs for details).\n\n```python\nraw_data = CovidMX(source='Serendipia', clean=False).get_data()\nconfirmed = CovidMX(source='Serendipia', kind=\"confirmed\").get_data()\nsuspects = CovidMX(source='Serendipia',kind=\"suspects\").get_data()\nparticular_published_date = CovidMX(source='Serendipia', date='2020-04-10', date_format='%Y-%m-%d').get_data()\n```\n\n# Cite as\n\n- Federico Garza Ramírez (2020). *covidmx: Python API to get information about COVID-19 in México*. Python package version 0.3.1. https://github.com/FedericoGarza/covidmx.\n\n# Acknowledgments\n\n- [Max Mergenthaler](https://github.com/mergenthaler)\n- [Mario Jimenez](https://github.com/isccarrasco)\n\n# Release information\n\n## 0.3.1 (Current version)\n\n- 2020-06-01\n- Updated new urls from serendipia source. (Thanks to [Mario Jimenez](https://github.com/isccarrasco).)\n\n## 0.3.0\n\n- 2020-04-26.\n- Includes a plot module at state and municipality leveles.\n- Includes a better handling of encodings. (Thanks to [Mario Jimenez](https://github.com/isccarrasco).)\n\n\n## 0.2.5\n\n- 2020-04-20. The [*Dirección General de Epidemiología*](https://www.gob.mx/salud/documentos/datos-abiertos-152127):\n  - Added an id column.\n  - Released historical information.\n  - Now the API can handle this changes.\n\n## 0.2.4\n\n- 2020-04-16. The [*Dirección General de Epidemiología*](https://www.gob.mx/salud/documentos/datos-abiertos-152127) source renamed two columns:\n  - `HABLA_LENGUA_INDI` -\u003e `HABLA_LENGUA_INDIG` (column name and description are now homologated)\n  - `OTRA_CON` -\u003e `OTRA_COM`\n  - Now the API can handle this change.\n\n## 0.2.3\n\n- Now works with `python3.5+`.\n- Using `clean=True` returns encoded data instead of decoded data without cleaning columns (as works in `0.2.0` and `0.2.1`).\n\n## 0.2.1\n\n- Minor changes to README.\n\n## 0.2.0\n\n- Added new source: [*Dirección General de Epidemiología*](https://www.gob.mx/salud/documentos/datos-abiertos-152127). Default source.\n- Only works with `python3.7+`.\n\n## 0.1.1\n\n- Minor changes to README.\n\n## 0.1.0\n\nFirst realease.\n\n- Only one source, [Serendipia](https://serendipia.digital/2020/03/datos-abiertos-sobre-casos-de-coronavirus-covid-19-en-mexico/). Default source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazulgarza%2Fcovidmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazulgarza%2Fcovidmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazulgarza%2Fcovidmx/lists"}