{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "cases = pd.read_csv('./data/WHO-COVID-19-global-data.csv')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Date_reportedCountry_codeCountryWHO_regionNew_casesCumulative_casesNew_deathsCumulative_deaths
02020-01-03AFAfghanistanEMRO0000
12020-01-04AFAfghanistanEMRO0000
22020-01-05AFAfghanistanEMRO0000
32020-01-06AFAfghanistanEMRO0000
42020-01-07AFAfghanistanEMRO0000
...........................
1644732021-11-22ZWZimbabweAFRO913364704699
1644742021-11-23ZWZimbabweAFRO2713367404699
1644752021-11-24ZWZimbabweAFRO3313370744703
1644762021-11-25ZWZimbabweAFRO4013374704703
1644772021-11-26ZWZimbabweAFRO2713377414704
\n", "

164478 rows × 8 columns

\n", "
" ], "text/plain": [ " Date_reported Country_code Country WHO_region New_cases \\\n", "0 2020-01-03 AF Afghanistan EMRO 0 \n", "1 2020-01-04 AF Afghanistan EMRO 0 \n", "2 2020-01-05 AF Afghanistan EMRO 0 \n", "3 2020-01-06 AF Afghanistan EMRO 0 \n", "4 2020-01-07 AF Afghanistan EMRO 0 \n", "... ... ... ... ... ... \n", "164473 2021-11-22 ZW Zimbabwe AFRO 9 \n", "164474 2021-11-23 ZW Zimbabwe AFRO 27 \n", "164475 2021-11-24 ZW Zimbabwe AFRO 33 \n", "164476 2021-11-25 ZW Zimbabwe AFRO 40 \n", "164477 2021-11-26 ZW Zimbabwe AFRO 27 \n", "\n", " Cumulative_cases New_deaths Cumulative_deaths \n", "0 0 0 0 \n", "1 0 0 0 \n", "2 0 0 0 \n", "3 0 0 0 \n", "4 0 0 0 \n", "... ... ... ... \n", "164473 133647 0 4699 \n", "164474 133674 0 4699 \n", "164475 133707 4 4703 \n", "164476 133747 0 4703 \n", "164477 133774 1 4704 \n", "\n", "[164478 rows x 8 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cases" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['EMRO', 'EURO', 'AFRO', 'WPRO', 'AMRO', 'SEARO', 'Other'],\n", " dtype=object)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cases.WHO_region.unique()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['Anguilla', 'Antigua and Barbuda', 'Argentina', 'Aruba', 'Bahamas',\n", " 'Barbados', 'Belize', 'Bermuda',\n", " 'Bolivia (Plurinational State of)', 'Bonaire', 'Brazil',\n", " 'British Virgin Islands', 'Canada', 'Cayman Islands', 'Chile',\n", " 'Colombia', 'Costa Rica', 'Cuba', 'Curaçao', 'Dominica',\n", " 'Dominican Republic', 'Ecuador', 'El Salvador',\n", " 'Falkland Islands (Malvinas)', 'French Guiana', 'Grenada',\n", " 'Guadeloupe', 'Guatemala', 'Guyana', 'Haiti', 'Honduras',\n", " 'Jamaica', 'Martinique', 'Mexico', 'Montserrat', 'Nicaragua',\n", " 'Panama', 'Paraguay', 'Peru', 'Puerto Rico', 'Saba',\n", " 'Saint Barthélemy', 'Saint Kitts and Nevis', 'Saint Lucia',\n", " 'Saint Martin', 'Saint Pierre and Miquelon',\n", " 'Saint Vincent and the Grenadines', 'Sint Eustatius',\n", " 'Sint Maarten', 'Suriname', 'Trinidad and Tobago',\n", " 'Turks and Caicos Islands', 'United States of America',\n", " 'United States Virgin Islands', 'Uruguay',\n", " 'Venezuela (Bolivarian Republic of)'], dtype=object)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cases.loc[cases.WHO_region == 'AMRO'].Country.unique()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Date_reportedCountry_codeCountryWHO_regionNew_casesCumulative_casesNew_deathsCumulative_deaths
1568442020-01-03USUnited States of AmericaAMRO0000
1568452020-01-04USUnited States of AmericaAMRO0000
1568462020-01-05USUnited States of AmericaAMRO0000
1568472020-01-06USUnited States of AmericaAMRO0000
1568482020-01-07USUnited States of AmericaAMRO0000
...........................
1575332021-11-22USUnited States of AmericaAMRO3233147405130269767185
1575342021-11-23USUnited States of AmericaAMRO3203647437166111767296
1575352021-11-24USUnited States of AmericaAMRO162130475992961269768565
1575362021-11-25USUnited States of AmericaAMRO102708477020041597770162
1575372021-11-26USUnited States of AmericaAMRO100455478024591367771529
\n", "

694 rows × 8 columns

\n", "
" ], "text/plain": [ " Date_reported Country_code Country WHO_region \\\n", "156844 2020-01-03 US United States of America AMRO \n", "156845 2020-01-04 US United States of America AMRO \n", "156846 2020-01-05 US United States of America AMRO \n", "156847 2020-01-06 US United States of America AMRO \n", "156848 2020-01-07 US United States of America AMRO \n", "... ... ... ... ... \n", "157533 2021-11-22 US United States of America AMRO \n", "157534 2021-11-23 US United States of America AMRO \n", "157535 2021-11-24 US United States of America AMRO \n", "157536 2021-11-25 US United States of America AMRO \n", "157537 2021-11-26 US United States of America AMRO \n", "\n", " New_cases Cumulative_cases New_deaths Cumulative_deaths \n", "156844 0 0 0 0 \n", "156845 0 0 0 0 \n", "156846 0 0 0 0 \n", "156847 0 0 0 0 \n", "156848 0 0 0 0 \n", "... ... ... ... ... \n", "157533 32331 47405130 269 767185 \n", "157534 32036 47437166 111 767296 \n", "157535 162130 47599296 1269 768565 \n", "157536 102708 47702004 1597 770162 \n", "157537 100455 47802459 1367 771529 \n", "\n", "[694 rows x 8 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cases.loc[cases.Country == 'United States of America']" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/alexkeeney/anaconda3/envs/bs/lib/python3.8/site-packages/pandas/core/frame.py:3607: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " self._set_item(key, value)\n" ] } ], "source": [ "us = cases.loc[cases.Country == 'United States of America']\n", "us.Date_reported = pd.to_datetime(us.Date_reported, format = '%Y-%m-%d')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Date_reportedCountry_codeCountryWHO_regionNew_casesCumulative_casesNew_deathsCumulative_deaths
1568442020-01-03USUnited States of AmericaAMRO0000
1568452020-01-04USUnited States of AmericaAMRO0000
1568462020-01-05USUnited States of AmericaAMRO0000
1568472020-01-06USUnited States of AmericaAMRO0000
1568482020-01-07USUnited States of AmericaAMRO0000
...........................
1575332021-11-22USUnited States of AmericaAMRO3233147405130269767185
1575342021-11-23USUnited States of AmericaAMRO3203647437166111767296
1575352021-11-24USUnited States of AmericaAMRO162130475992961269768565
1575362021-11-25USUnited States of AmericaAMRO102708477020041597770162
1575372021-11-26USUnited States of AmericaAMRO100455478024591367771529
\n", "

694 rows × 8 columns

\n", "
" ], "text/plain": [ " Date_reported Country_code Country WHO_region \\\n", "156844 2020-01-03 US United States of America AMRO \n", "156845 2020-01-04 US United States of America AMRO \n", "156846 2020-01-05 US United States of America AMRO \n", "156847 2020-01-06 US United States of America AMRO \n", "156848 2020-01-07 US United States of America AMRO \n", "... ... ... ... ... \n", "157533 2021-11-22 US United States of America AMRO \n", "157534 2021-11-23 US United States of America AMRO \n", "157535 2021-11-24 US United States of America AMRO \n", "157536 2021-11-25 US United States of America AMRO \n", "157537 2021-11-26 US United States of America AMRO \n", "\n", " New_cases Cumulative_cases New_deaths Cumulative_deaths \n", "156844 0 0 0 0 \n", "156845 0 0 0 0 \n", "156846 0 0 0 0 \n", "156847 0 0 0 0 \n", "156848 0 0 0 0 \n", "... ... ... ... ... \n", "157533 32331 47405130 269 767185 \n", "157534 32036 47437166 111 767296 \n", "157535 162130 47599296 1269 768565 \n", "157536 102708 47702004 1597 770162 \n", "157537 100455 47802459 1367 771529 \n", "\n", "[694 rows x 8 columns]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "us" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "import altair as alt" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "alt.Chart(us).mark_line().encode(\n", " x = 'Date_reported:T', \n", " y = 'New_cases'\n", ")" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "alt.Chart(us).mark_line().encode(\n", " x = 'Date_reported:T', \n", " y = 'New_deaths'\n", ")" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "alt.Chart(us).mark_line().encode(\n", " x = 'Date_reported:T', \n", " y = 'Cumulative_cases'\n", ")" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "alt.Chart(us).mark_line().encode(\n", " x = 'Date_reported:T', \n", " y = 'Cumulative_deaths'\n", ")" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "alt.Chart(\n", " us.loc[us.Date_reported > pd.Timestamp('07-15-2021')]\n", ").mark_line().encode(\n", " x = 'Date_reported:T', \n", " y = 'New_cases'\n", ")" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "alt.Chart(\n", " us.loc[us.Date_reported > pd.Timestamp('07-15-2021')]\n", ").mark_line().encode(\n", " x = 'Date_reported:T', \n", " y = 'Cumulative_cases'\n", ")" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "us_delta = us.loc[us.Date_reported > pd.Timestamp('07-15-2021')].copy()" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "157404 0\n", "157405 40447\n", "157406 82632\n", "157407 113953\n", "157408 142189\n", " ... \n", "157533 13592445\n", "157534 13624481\n", "157535 13786611\n", "157536 13889319\n", "157537 13989774\n", "Name: Cumulative_cases, Length: 134, dtype: int64" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "us_delta.Cumulative_cases \\\n", "- us_delta.Cumulative_cases.min()" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "us_delta['new_cumulative_cases'] = us_delta.Cumulative_cases - us_delta.Cumulative_cases.min()" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "alt.Chart(\n", " us_delta\n", ").mark_line().encode(\n", " x = 'Date_reported:T', \n", " y = 'new_cumulative_cases'\n", ")" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "us_delta.to_csv('./data/us_july_15-present.csv')" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Date_reportedCountry_codeCountryWHO_regionNew_casesCumulative_casesNew_deathsCumulative_deathsnew_cumulative_cases
1574532021-09-03USUnited States of AmericaAMRO1984533931798119946461325505296
\n", "
" ], "text/plain": [ " Date_reported Country_code Country WHO_region \\\n", "157453 2021-09-03 US United States of America AMRO \n", "\n", " New_cases Cumulative_cases New_deaths Cumulative_deaths \\\n", "157453 198453 39317981 1994 646132 \n", "\n", " new_cumulative_cases \n", "157453 5505296 " ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "max_cases = us_delta.New_cases.max()\n", "us_delta.loc[us_delta.New_cases == max_cases]\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "interpreter": { "hash": "76cde62e0228cff324f50159dac87965e4f2f2cc02db9900345b7f4e3657d2e6" }, "kernelspec": { "display_name": "Python 3.8.11 64-bit ('bs': conda)", "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.8.11" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }