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): Simultaneous usage of named_expr and schema in pl.struct #17768

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

SandroCasagrande
Copy link
Contributor

Resolves #16509

The fix seem very simple. I added a test that shows the (imho) expected behavior.

Copy link

codecov bot commented Jul 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.42%. Comparing base (7888d3b) to head (58f5a72).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17768      +/-   ##
==========================================
- Coverage   80.44%   80.42%   -0.02%     
==========================================
  Files        1502     1502              
  Lines      197073   197075       +2     
  Branches     2794     2794              
==========================================
- Hits       158539   158503      -36     
- Misses      38020    38058      +38     
  Partials      514      514              

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

def test_named_exprs() -> None:
df = pl.DataFrame({"a": 1})
schema = {"b": pl.Int64}
res = df.select(pl.struct(schema=schema, b=pl.col("a")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

res and expect seem to be the exact same query. Can you check the valid outputs via a assert res.to_dict(as_series=False) == expected

and a res.schema == expected_schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I made that part more direct. Thanks @ritchie46 .

@ritchie46
Copy link
Member

Thanks

@ritchie46 ritchie46 merged commit 26346cf into pola-rs:main Jul 22, 2024
14 checks passed
atigbadr pushed a commit to atigbadr/polars that referenced this pull request Jul 23, 2024
…truct` (pola-rs#17768)

Co-authored-by: Casagrande, Sandro <sandro.casagrande@techem.de>
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.

pl.struct usage of schema renders keyword argument renaming ineffective
2 participants