Skip to content

Conversation

@wtn
Copy link
Contributor

@wtn wtn commented Dec 4, 2025

Fixes #22591.

Series.replace() and Series.replace_strict() panic when old or new is a list containing Expr objects.

Add validation in Expr.replace() and Expr.replace_strict() to raise TypeError for this case.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Dec 4, 2025
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.10%. Comparing base (5dd9b23) to head (1fc0d25).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25612      +/-   ##
==========================================
+ Coverage   78.35%   81.10%   +2.74%     
==========================================
  Files        1777     1777              
  Lines      241720   241757      +37     
  Branches     3085     3095      +10     
==========================================
+ Hits       189406   196072    +6666     
+ Misses      51517    44888    -6629     
  Partials      797      797              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mcrumiller
Copy link
Contributor

Could we instead convert a replace into a when/then sequence if we encounter expressions in the replacement?

@wtn wtn force-pushed the replace branch 6 times, most recently from 86097b4 to 3b32fd1 Compare December 10, 2025 19:55
@wtn wtn marked this pull request as ready for review December 10, 2025 19:56
@wtn wtn force-pushed the replace branch 2 times, most recently from cee92ea to 757884c Compare December 20, 2025 02:42
@wtn wtn force-pushed the replace branch 2 times, most recently from 44e2080 to 92a06de Compare January 7, 2026 17:34
@wtn wtn force-pushed the replace branch 4 times, most recently from 68dc7f9 to 6584d15 Compare January 16, 2026 17:38
@wtn wtn force-pushed the replace branch 4 times, most recently from 186bb61 to 43718bb Compare January 22, 2026 01:42
@wtn wtn changed the title fix(python): Reject Expr objects in replace sequence arguments fix(python): Support Expr objects in replace sequence arguments Jan 22, 2026
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix python Related to Python Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

replace with invalid args PanicException

2 participants