Skip to content

Instantly share code, notes, and snippets.

@codebrain001
Created April 23, 2020 20:02
Show Gist options
  • Save codebrain001/f1f964f8a4ad9f4ac5b8b9770cad3c47 to your computer and use it in GitHub Desktop.
Save codebrain001/f1f964f8a4ad9f4ac5b8b9770cad3c47 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"# to suppress future warnings\n",
"import warnings\n",
"warnings.simplefilter(action='ignore', category=FutureWarning)\n",
"\n",
"import pandas as pd\n",
"import dask.dataframe as dd\n",
"\n",
"dt = pd.DataFrame(data)\n",
"dt = pd.DataFrame(data[1:], columns=data[0][:12]) #Formatting the header\n",
"df = dd.from_pandas(dt,npartitions=1)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"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>Country,Other</th>\n",
" <th>TotalCases</th>\n",
" <th>NewCases</th>\n",
" <th>TotalDeaths</th>\n",
" <th>NewDeaths</th>\n",
" <th>TotalRecovered</th>\n",
" <th>ActiveCases</th>\n",
" <th>Serious,Critical</th>\n",
" <th>Tot Cases/1M pop</th>\n",
" <th>Deaths/1M pop</th>\n",
" <th>TotalTests</th>\n",
" <th>Tests/</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>World</td>\n",
" <td>2,632,532</td>\n",
" <td>+76,772</td>\n",
" <td>183,866</td>\n",
" <td>+6,407</td>\n",
" <td>716,877</td>\n",
" <td>1,731,789</td>\n",
" <td>56,678</td>\n",
" <td>338</td>\n",
" <td>23.6</td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>USA</td>\n",
" <td>846,294</td>\n",
" <td>+27,550</td>\n",
" <td>47,524</td>\n",
" <td>+2,206</td>\n",
" <td>83,917</td>\n",
" <td>714,853</td>\n",
" <td>14,014</td>\n",
" <td>2,557</td>\n",
" <td>144</td>\n",
" <td>4,319,358</td>\n",
" <td>13,049</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Spain</td>\n",
" <td>208,389</td>\n",
" <td>+4,211</td>\n",
" <td>21,717</td>\n",
" <td>+435</td>\n",
" <td>85,915</td>\n",
" <td>100,757</td>\n",
" <td>7,705</td>\n",
" <td>4,457</td>\n",
" <td>464</td>\n",
" <td>930,230</td>\n",
" <td>19,896</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Italy</td>\n",
" <td>187,327</td>\n",
" <td>+3,370</td>\n",
" <td>25,085</td>\n",
" <td>+437</td>\n",
" <td>54,543</td>\n",
" <td>107,699</td>\n",
" <td>2,384</td>\n",
" <td>3,098</td>\n",
" <td>415</td>\n",
" <td>1,513,251</td>\n",
" <td>25,028</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>France</td>\n",
" <td>159,877</td>\n",
" <td>+1,827</td>\n",
" <td>21,340</td>\n",
" <td>+544</td>\n",
" <td>40,657</td>\n",
" <td>97,880</td>\n",
" <td>5,218</td>\n",
" <td>2,449</td>\n",
" <td>327</td>\n",
" <td>463,662</td>\n",
" <td>7,103</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country,Other TotalCases NewCases TotalDeaths NewDeaths TotalRecovered \\\n",
"0 World 2,632,532 +76,772 183,866 +6,407 716,877 \n",
"1 USA 846,294 +27,550 47,524 +2,206 83,917 \n",
"2 Spain 208,389 +4,211 21,717 +435 85,915 \n",
"3 Italy 187,327 +3,370 25,085 +437 54,543 \n",
"4 France 159,877 +1,827 21,340 +544 40,657 \n",
"\n",
" ActiveCases Serious,Critical Tot Cases/1M pop Deaths/1M pop TotalTests \\\n",
"0 1,731,789 56,678 338 23.6 \n",
"1 714,853 14,014 2,557 144 4,319,358 \n",
"2 100,757 7,705 4,457 464 930,230 \n",
"3 107,699 2,384 3,098 415 1,513,251 \n",
"4 97,880 5,218 2,449 327 463,662 \n",
"\n",
" Tests/ \n",
"0 \n",
"1 13,049 \n",
"2 19,896 \n",
"3 25,028 \n",
"4 7,103 "
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment