Repository navigation
inflation_history, fitting_distributions: state what pandas now warns about - #876
Conversation
… about Two cells printed a pandas warning into their output: - inflation_history: pd.concat of the sheets, which all have a DatetimeIndex, sorts the joined index by default, which pandas 3 deprecates (Pandas4Warning: "Sorting by default when concatenating all DatetimeIndex is deprecated"). `sort=True` keeps today's sorted result. - fitting_distributions: `times` is in UTC, and converting it to monthly periods drops the time zone, with a UserWarning. Dropping it first with `tz_localize(None)` gives the same months, without the warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WT8bMacV9Lmy1VLUc6XJoL
✅ Deploy Preview for taupe-gaufre-c4e660 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Validation: a full validationTwo fresh builds with no cache, each executing all 54 notebooks,
This pull request's first fresh build, 45012267153, failed on eight pages, all with HTTP 429 (Too Many Requests) while downloading data from QuantEcon/data-lectures. That day thirteen validation builds started at once, and GitHub rate-limited the downloads. The run above is the same build again, later. The two changed lectures. In each, the only difference is the changed line itself and the warning, which is gone. Every other output is identical, and so is every figure, byte for byte.
Build logs. The same warning lines on both sides, and no Sphinx warning on either. The rest of the HTML. 20 of 66 pages differ in all. Besides the two above, there are three kinds of difference, as between any two builds:
The warnings in the other pages' outputs are the same on both sides. |
There was a problem hiding this comment.
🔵 Needs a closer look
Human review is needed to confirm that the executable lecture changes preserve the intended pandas-version-specific warning behavior and instructional outputs across regenerated notebooks and external data.
No open issues 🎉
What changed in this PR
This PR updates two executable lecture examples to make pandas behavior explicit, removing deprecation and timezone-conversion warnings while preserving existing results.
Changes:
- Sets
sort=Truewhen concatenating time-indexed data ininflation_history. - Removes timezone information before converting timestamps to monthly periods in
fitting_distributions. - No actionable code issues identified.
| File | Description |
|---|---|
| lectures/inflation_history.md | Makes the concatenation sort behavior explicit for pandas compatibility. |
| lectures/fitting_distributions.md | Removes UTC timezone information before monthly period conversion. |
Review effort: Lite (adaptive)
The previous commit removed the time zone with `tz_localize(None)`
before `to_period('M')`, because pandas warns that converting UTC times
to periods drops the zone. `quakes.set_index(times).resample('MS').size()`
counts the events in each calendar month directly: it needs no time-zone
step and gives no warning. It also counts a month with no earthquakes as
0, where `value_counts` leaves that month out, and the comparison of the
mean with the variance that follows needs those zeros.
On japan_earthquakes.csv every one of the 300 months has an event, so
the printed mean and variance are unchanged (11.857 and 1148.98).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WT8bMacV9Lmy1VLUc6XJoL
Validation of 6280118: a full validation6280118 changes one line in fitting_distributions, from
The two changed lectures. Both warnings are gone. fitting_distributions prints the same mean and variance as main, Build logs. The same warning lines on both sides, and no Sphinx warning on either. The rest of the HTML. 20 of 66 pages differ in all: the same 20 as in the first validation, for the same reasons (random draws, memory addresses and timings, figure file names, and the status page's build times). Every other page's output warnings are the same on both sides. Compared with this pull request's build at |
✅ Translation sync completed (zh-cn)Target repo: QuantEcon/lecture-intro.zh-cn
|
What
Two cells print a pandas warning into their output. This states what pandas asks for, keeping the results the same:
df_list.append(pd.concat(sheet_list, axis=1))df_list.append(pd.concat(sheet_list, axis=1, sort=True))sort=False."sort=Truekeeps today's sorted result.monthly = times.dt.to_period('M').value_counts().sort_index()monthly = quakes.set_index(times).resample('MS').size()timesis in UTC, and a period has no time zone.resamplecounts the events in each calendar month directly, with no time-zone step and no warning, and counts a month with no earthquakes as 0, wherevalue_countsleaves it out; the comparison of the mean with the variance that follows needs those zeros. Every one of the 300 months has an event, so the printed mean and variance are unchanged.Both were found by the environment scan of 2026-11-19 and are in intro's own builds. This is part of reporting lecture fixes upstream to each lecture's source of truth (QuantEcon/project-monorepo#77).
Validation
Done on 2026-11-22, a full validation; the evidence is in the comments below. The fitting_distributions line changed after that validation, from
tz_localize(None)andto_period('M')toresample('MS')(6280118); its own validation follows in a comment. Fresh builds with no cache of this pull request and of main, every notebook executed, both green. In the two lectures both warnings are gone, and every other output and figure is identical.This changes lecture content, so it needs a person's review.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMacV9Lmy1VLUc6XJoL