Skip to content

Fix Yes/No flag dtype in notebooks 4.2-4.5 for pandas 3 - #19

Merged
erikfilias merged 1 commit into
mainfrom
fix/notebooks-4x-yesno-dtype
Jul 20, 2026
Merged

Fix Yes/No flag dtype in notebooks 4.2-4.5 for pandas 3#19
erikfilias merged 1 commit into
mainfrom
fix/notebooks-4x-yesno-dtype

Conversation

@erikfilias

Copy link
Copy Markdown
Contributor

The 4.x notebooks set a Yes/No option flag on a case CSV before solving, e.g. gen.loc[mask, "BinaryCommitment"] = "Yes". When that column is empty in the case file, pandas reads it as all-NaN float64. pandas 3 raises TypeError: Invalid value 'Yes' for dtype 'float64' instead of silently upcasting, so the scheduled submodule-bump job failed at notebook 4.2 once the fresh conda build pulled pandas 3. Notebooks 4.4 and 4.5 hit the same wall next; 4.3 works today only because its column already holds strings.

This casts the target column to object before the assignment (a no-op where the column is already object).

Verified against openTEPES master tip 4ec96bd4 with pandas 3.0.3 on Python 3.12: 4.2, 4.3, 4.4 and 4.5 all solve with no error cells (200.02 / 161.603 / 197.32 / 191.141 MEUR).

The 4.x notebooks set a Yes/No option flag on a case CSV, e.g.
gen.loc[mask, "BinaryCommitment"] = "Yes". When that column is empty in
the case file, pandas reads it as all-NaN float64. pandas 3 raises
TypeError: Invalid value 'Yes' for dtype 'float64' instead of silently
upcasting, so the scheduled submodule-bump job failed at notebook 4.2 once
the fresh conda build pulled pandas 3.

Cast the target column to object before the assignment. This is a no-op
where the column already holds strings (4.3).

Verified against openTEPES master tip 4ec96bd4 with pandas 3.0.3 on
Python 3.12: 4.2, 4.3, 4.4 and 4.5 all solve with no error cells.
@erikfilias
erikfilias merged commit 2eabac5 into main Jul 20, 2026
1 check passed
@erikfilias
erikfilias deleted the fix/notebooks-4x-yesno-dtype branch July 20, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant