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

allow concat/append expressions #3541

Merged
merged 1 commit into from
May 31, 2022
Merged

allow concat/append expressions #3541

merged 1 commit into from
May 31, 2022

Conversation

ritchie46
Copy link
Member

I found it pretty hard to extend a DataFrame with nulls. So I have added append, concat and rechunk functionality to the expressions.

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

assert df.select(
    pl.repeat(None, 3).append(pl.col("a"))
).n_chunks() == 2

assert df.select(
    pl.repeat(None, 3).append(pl.col("a")).rechunk()
).n_chunks() == 1


out = df.select(
    pl.concat([pl.repeat(None, 3), pl.col("a")])
)

assert out.n_chunks() == 1
assert out.to_series().to_list() == [None, None, None, 1, 1, 2]

@github-actions github-actions bot added python Related to Python Polars rust Related to Rust Polars labels May 31, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #3541 (2487d30) into master (77ae80a) will decrease coverage by 0.01%.
The diff coverage is 91.11%.

@@            Coverage Diff             @@
##           master    #3541      +/-   ##
==========================================
- Coverage   77.52%   77.51%   -0.02%     
==========================================
  Files         425      425              
  Lines       71025    71068      +43     
==========================================
+ Hits        55064    55089      +25     
- Misses      15961    15979      +18     
Impacted Files Coverage Δ
py-polars/polars/internals/functions.py 90.76% <83.33%> (-1.96%) ⬇️
polars/polars-lazy/src/dsl/mod.rs 91.13% <89.47%> (-0.03%) ⬇️
py-polars/polars/internals/expr.py 95.52% <100.00%> (+0.03%) ⬆️
py-polars/src/lazy/dsl.rs 91.18% <100.00%> (+0.05%) ⬆️
...polars-core/src/chunked_array/iterator/par/list.rs 95.23% <0.00%> (-4.77%) ⬇️
polars/polars-core/src/vector_hasher.rs 75.00% <0.00%> (-1.62%) ⬇️
polars/polars-core/src/frame/mod.rs 77.10% <0.00%> (-0.64%) ⬇️
polars/polars-io/src/csv_core/utils.rs 79.18% <0.00%> (-0.48%) ⬇️
...olars/polars-core/src/frame/groupby/into_groups.rs 59.93% <0.00%> (-0.31%) ⬇️
...lars/polars-core/src/chunked_array/builder/list.rs 63.89% <0.00%> (-0.29%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77ae80a...2487d30. Read the comment docs.

@ritchie46 ritchie46 merged commit a36c992 into master May 31, 2022
@ritchie46 ritchie46 deleted the expr_change_lens branch May 31, 2022 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants