From fd33799e7570646090709bbc289ec1cc537c95cd Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Tue, 18 Aug 2026 10:59:53 +1000 Subject: [PATCH] Read the three wave-C2 datasets from data-lectures (Track C) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fred_data.csv drops the own-repo raw URL (refs/heads/main spelling, split across string literals) for the data-lectures form. acs_data_summary.csv goes from a local _static path to the same URL prefix. five_preferences.md swaps loadmat('dataBHS.mat') for read_csv of the converted dataBHS.csv, dropping the scipy.io import for pandas; the (236, 1) column shape is preserved via a [['c']] selection so every downstream array — the growth difference, the histogram, and the ax.hist patch-container indexing — is shape-identical to the loadmat path. Histogram counts and bin edges verified identical under pandas' default parser before the edit. Data landed first in QuantEcon/data-lectures#98; this repo caches notebook execution, so these cells re-execute against data-lectures main. The local copies are deleted in a follow-up PR after this one publishes — fred_data.csv is a live runtime fetch with no stale-serving grace period. Co-Authored-By: Claude Fable 5 --- lectures/five_preferences.md | 6 +++--- lectures/match_transport.md | 4 ++-- lectures/risk_aversion_or_mistaken_beliefs.md | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lectures/five_preferences.md b/lectures/five_preferences.md index 2af863da..8068c139 100644 --- a/lectures/five_preferences.md +++ b/lectures/five_preferences.md @@ -59,7 +59,7 @@ import matplotlib as mpl import matplotlib.pyplot as plt from matplotlib import rc from scipy import optimize, stats -from scipy.io import loadmat +import pandas as pd from matplotlib.collections import LineCollection from numba import njit ``` @@ -1845,7 +1845,7 @@ aversion associated with a logarithmic one-period utility function. :tags: [hide-input] # Load data -data = loadmat('dataBHS.mat') +data = pd.read_csv('https://github.com/QuantEcon/data-lectures/raw/main/lectures/dataBHS.csv') # Set parameter values μ_c = 0.004952 @@ -1857,7 +1857,7 @@ data = loadmat('dataBHS.mat') :tags: [hide-input] # Compute consumption growth -c = data['c'] +c = data[['c']].to_numpy() # keep the (236, 1) column shape of the source arrays c_growth = c[1:] - c[:-1] # Create histogram of consumption growth diff --git a/lectures/match_transport.md b/lectures/match_transport.md index 852dea9d..4c6555ec 100644 --- a/lectures/match_transport.md +++ b/lectures/match_transport.md @@ -2231,8 +2231,8 @@ Then we sort occupations by average log-earnings within each occupation. The resulting dataset is included in the dataset `acs_data_summary.csv` ```{code-cell} ipython3 -data_path = '_static/lecture_specific/match_transport/' -occupation_df = pd.read_csv(data_path + 'acs_data_summary.csv') +data_url = 'https://github.com/QuantEcon/data-lectures/raw/main/lectures/' +occupation_df = pd.read_csv(data_url + 'acs_data_summary.csv') ``` +++ {"user_expressions": []} diff --git a/lectures/risk_aversion_or_mistaken_beliefs.md b/lectures/risk_aversion_or_mistaken_beliefs.md index 949d2b0c..9284b0e4 100644 --- a/lectures/risk_aversion_or_mistaken_beliefs.md +++ b/lectures/risk_aversion_or_mistaken_beliefs.md @@ -1611,8 +1611,7 @@ mystnb: name: fig-us-yields --- data = pd.read_csv( - 'https://raw.githubusercontent.com/QuantEcon/lecture-python-advanced.myst/refs/heads/' - 'main/lectures/_static/lecture_specific/risk_aversion_or_mistaken_beliefs/fred_data.csv', + 'https://github.com/QuantEcon/data-lectures/raw/main/lectures/fred_data.csv', parse_dates=['DATE'], index_col='DATE' )