Last active
October 19, 2020 17:59
-
-
Save nicoguaro/5bbb49e1ad6c575a3216cf53480d03a5 to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cumulative deaths Fall in GDP | |
0 1.73 | |
5 0.36 | |
7 -13.41 | |
9 -4.41 | |
13 -8.45 | |
14 -13.09 | |
20 -9.23 | |
28 -14.18 | |
34 -7.23 | |
37 -5.73 | |
43 -14.55 | |
45 -7.55 | |
51 -6.68 | |
52 -7.68 | |
65 -5.64 | |
69 -14.23 | |
78 -9.23 | |
80 -24.77 | |
93 -11.73 | |
97 -14.27 | |
98 -14.86 | |
105 -11.00 | |
117 -8.82 | |
118 -11.45 | |
128 -9.64 | |
147 -5.82 | |
158 -4.08 | |
204 -17.18 | |
208 -10.46 | |
210 -8.49 | |
219 -9.72 | |
255 -13.38 | |
281 -11.92 | |
304 -16.73 | |
372 -7.95 | |
379 -9.91 | |
488 -18.80 | |
531 -19.68 | |
554 -16.65 | |
573 -8.14 | |
600 -17.85 | |
627 -10.02 | |
641 -21.83 | |
658 -17.97 | |
700 -22.06 | |
701 -10.55 | |
713 -11.86 | |
887 -15.09 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Deaths vs GDP fall in 2020 | |
Response to the following tweet: | |
https://twitter.com/ianbremmer/status/1317924980659785728 | |
@author: Nicolas Guarin-Zapata | |
@date: October 2020 | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.stats import linregress | |
plt.style.use("fivethirtyeight") | |
deaths = np.loadtxt("deaths_gdp.csv", usecols=(0,), skiprows=1) | |
gdp = np.loadtxt("deaths_gdp.csv", usecols=(1,), skiprows=1) | |
# Linear regression | |
slope, intercept, r_value, p_value, std_err = linregress(deaths, | |
gdp) | |
# Plots | |
plt.plot(deaths, gdp, "o") | |
plt.plot(deaths, slope*deaths + intercept) | |
plt.text(600, 0, "$R^2 = %.3f$" % (r_value**2)) | |
plt.xlabel("Cumulative deaths per million, Oct 14 2020") | |
plt.ylabel("Fall in GDP 2020 H1 (%)") | |
plt.savefig("deaths_gdp_fall.png", dpi=300) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment