fix: replace pandas APIs removed in 2.0 that leave four entry points … - #1320
Open
EnvDroneSense wants to merge 1 commit into
Open
fix: replace pandas APIs removed in 2.0 that leave four entry points …#1320EnvDroneSense wants to merge 1 commit into
EnvDroneSense wants to merge 1 commit into
Conversation
EnvDroneSense
requested review from
chahank,
emanuel-schmid and
peanutfun
as code owners
September 7, 2026 21: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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this PR:
DataFrame.appendandSeries.iteritems, removed in pandas 2.0, that make their enclosing functions raiseAttributeError:litpop.py:640,impact_data.py:422,calibration_opt.py:406andcalibration_opt.py:94.This PR fixes #1319 and #826
The affected entry points are
LitPop.from_shape_and_countries(with aGeoSeriesorlistshape),impact_data.hit_country_per_hazard,calibration_opt.calib_all, andcalibration_opt.calib_instance(with a multi-rowdf_outandyearly_impact=True).pyproject.tomldeclarespandaswith no version constraint, so a fresh install always resolves to an affected version.litpop.py:640is the cause of #826; that issue's traceback names this line, and its reporter proposed the same patch.The fix differs by site.
litpop.pyandcalibration_opt.py:406accumulate DataFrames, so they collect into a list andpd.concatonce, which also removes the quadratic copy the loops paid.impact_data.py:422appends a dict rather than a frame, so it collects records and builds onepd.DataFrame(records, columns=[...]).calibration_opt.py:94is a rename.Two behaviour details worth review:
calib_allreturns the single frame directly when there is exactly one parameter combination. The old code deep-copied the firstdf_outand only appliedignore_index=Truefrom the second onward, so a caller-suppliedimpact_data_sourceindex survived;pd.concat(..., ignore_index=True)alone would silently replace it.litpop.pythe type check moved out of the loop, ahead of any selection. Previously[Polygon, Point]ran a full point-in-polygon pass for the polygon before raising on the point.Also
calibration_opt.py:406passed the builtininputas the second positional argument (ignore_index).bool(input)isTrue, so it happened to meanignore_index=True.Each test was checked by reverting its own fix alone, with the other three in place:
Note there is precedent for this bug class here:
test_emdat_impact_yearlysum_no_futurewarningwas added when the same.appendproblem was fixed inemdat_impact_yearlysum. This brings the remaining four sites in line with that.PR Author Checklist
develop)PR Reviewer Checklist