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

Open
wants to merge 2 commits 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.63%. Comparing base (099ee3c) to head (8f7b308).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20778      +/-   ##
==========================================
- Coverage   79.63%   79.63%   -0.01%     
==========================================
  Files        1568     1568              
  Lines      222970   222974       +4     
  Branches     2544     2545       +1     
==========================================
+ Hits       177555   177558       +3     
- Misses      44831    44832       +1     
  Partials      584      584              

☔ 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.

@mcrumiller mcrumiller marked this pull request as ready for review January 20, 2025 22:30
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