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: Fix map_elements ignoring skip_nulls=True for struct dtype #20668

Merged
merged 4 commits into from
Jan 12, 2025

Conversation

lukemanley
Copy link
Contributor

closes #10102

import polars as pl

df = pl.DataFrame(
    {
        "a": [{"b": 1}, None],
    }
)

df.select(
    pl.col("a").map_elements(lambda x: x["b"], skip_nulls=True)
)

main:

polars.exceptions.ComputeError: TypeError: 'NoneType' object is not subscriptable

This PR:

shape: (2, 1)
┌──────┐
│ a    │
│ ---  │
│ i64  │
╞══════╡
│ 1    │
│ null │
└──────┘

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Jan 11, 2025
Copy link

codecov bot commented Jan 11, 2025

Codecov Report

Attention: Patch coverage is 78.04878% with 9 lines in your changes missing coverage. Please review.

Project coverage is 78.99%. Comparing base (87baf86) to head (52e7193).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-python/src/map/series.rs 74.28% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20668      +/-   ##
==========================================
+ Coverage   78.85%   78.99%   +0.13%     
==========================================
  Files        1558     1558              
  Lines      221055   221083      +28     
  Branches     2527     2527              
==========================================
+ Hits       174318   174647     +329     
+ Misses      46159    45858     -301     
  Partials      578      578              

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

@ritchie46
Copy link
Member

Nice, can we add a test where we test both ignore as non-ignore case?

@ritchie46 ritchie46 merged commit a433272 into pola-rs:main Jan 12, 2025
27 checks passed
@lukemanley lukemanley deleted the fix-map-elements-struct-nulls branch January 12, 2025 12:35
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.

.apply(skip_nulls=True) seems to be ignored for struct types
2 participants