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

feat: Support any iterator for from_rows_iter_and_schema #21227

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

Conversation

eranfu
Copy link

@eranfu eranfu commented Feb 13, 2025

Change the item of from_rows_iter_and_schema from &Row to IntoIterator<Item = AnyValue>

Users can make a DataFrame without creating the Vec or unsafe Row buffer

@eranfu eranfu changed the title feat: Change the item of from_rows_iter_and_schema from &Row to `… feat: Support any iterator for from_rows_iter_and_schema Feb 13, 2025
@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars and removed title needs formatting labels Feb 13, 2025
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

Attention: Patch coverage is 83.13253% with 14 lines in your changes missing coverage. Please review.

Project coverage is 79.75%. Comparing base (0654544) to head (56edea2).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-python/src/map/dataframe.rs 61.11% 7 Missing ⚠️
crates/polars-core/src/frame/row/av_buffer.rs 86.84% 5 Missing ⚠️
...pipe/src/executors/sinks/group_by/primitive/mod.rs 66.66% 1 Missing ⚠️
...polars-pipe/src/executors/sinks/group_by/string.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21227      +/-   ##
==========================================
- Coverage   79.88%   79.75%   -0.13%     
==========================================
  Files        1593     1594       +1     
  Lines      227754   228109     +355     
  Branches     2600     2600              
==========================================
- Hits       181937   181930       -7     
- Misses      45220    45582     +362     
  Partials      597      597              

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

@@ -40,65 +40,36 @@ impl DataFrame {
/// This should only be used when you have row wise data, as this is a lot slower
/// than creating the [`Series`] in a columnar fashion
pub fn from_rows_and_schema(rows: &[Row], schema: &Schema) -> PolarsResult<Self> {
Self::from_rows_iter_and_schema(rows.iter(), schema)
Self::from_rows_iter_and_schema(rows.iter().cloned(), schema)
Copy link
Member

Choose a reason for hiding this comment

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

This now clones every row we add? I am for making this more generic, but we should not clone vec buffers for every row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature 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