Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(python): Add height check to frame-level row indexing when key is int #20778

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mcrumiller
Copy link
Contributor

@mcrumiller mcrumiller commented Jan 17, 2025

Closes #20775.

The issue is that df.slice(idx, 1) was being called for a single integer index key, and slices return the empty set instead of raising when idx is out of bounds. This PR adds a small height check.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Jan 17, 2025
@mcrumiller mcrumiller marked this pull request as draft January 17, 2025 21:08
@mcrumiller mcrumiller marked this pull request as ready for review January 17, 2025 21:08
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.77%. Comparing base (6753bb6) to head (588d19a).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20778      +/-   ##
==========================================
+ Coverage   79.74%   79.77%   +0.03%     
==========================================
  Files        1561     1561              
  Lines      222012   221925      -87     
  Branches     2530     2531       +1     
==========================================
+ Hits       177043   177044       +1     
+ Misses      44387    44299      -88     
  Partials      582      582              

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

@mcrumiller mcrumiller changed the title fix: Add height check to frame-level row indexing when key is int fix(python): Add height check to frame-level row indexing when key is int Jan 17, 2025
@mcrumiller mcrumiller marked this pull request as draft January 19, 2025 23:21
@mcrumiller
Copy link
Contributor Author

Need to check negative indexing as well.

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 rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No exception when empty DataFrames indexed out of bounds
1 participant