From 5fb3ffd00c4bae6aa159141dfa78a5a339d48a12 Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 20 Feb 2024 16:36:44 +1100 Subject: [PATCH] update data location --- lectures/simple_linear_regression.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lectures/simple_linear_regression.md b/lectures/simple_linear_regression.md index daa81945..af7ac960 100644 --- a/lectures/simple_linear_regression.md +++ b/lectures/simple_linear_regression.md @@ -356,13 +356,13 @@ Let's consider two economic variables GDP per capita and Life Expectancy. ::: -You can download {download}`a copy of the data here <_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv>` if you get stuck +You can download {download}`a copy of the data here ` if you get stuck **Q3:** Use `pandas` to import the `csv` formatted data and plot a few different countries of interest ```{code-cell} ipython3 -fl = "_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv" # TODO: Replace with GitHub link -df = pd.read_csv(fl, nrows=10) +data_url = "https://github.com/QuantEcon/lecture-python-intro/raw/main/lectures/_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv" +df = pd.read_csv(data_url, nrows=10) ``` ```{code-cell} ipython3 @@ -446,7 +446,7 @@ df = df[df.year == 2018].reset_index(drop=True).copy() ``` ```{code-cell} ipython3 -df.plot(x='gdppc', y='life_expectancy', kind='scatter', xlabel="GDP per capita", ylabel="Life Expectancy (Years)",); +df.plot(x='gdppc', y='life_expectancy', kind='scatter', xlabel="GDP per capita", ylabel="Life expectancy (years)",); ``` This data shows a couple of interesting relationships. @@ -463,7 +463,7 @@ ln -> ln == elasticities By specifying `logx` you can plot the GDP per Capita data on a log scale ```{code-cell} ipython3 -df.plot(x='gdppc', y='life_expectancy', kind='scatter', xlabel="GDP per capita", ylabel="Life Expectancy (Years)", logx=True); +df.plot(x='gdppc', y='life_expectancy', kind='scatter', xlabel="GDP per capita", ylabel="Life expectancy (years)", logx=True); ``` As you can see from this transformation -- a linear model fits the shape of the data more closely.