Skip to content

Commit

Permalink
respect n_rows (#3624)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jun 8, 2022
1 parent f7aa58c commit 063b22d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions polars/polars-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,20 @@ pub(crate) fn finish_reader<R: ArrowReader>(

apply_aggregations(&mut df, aggregate)?;

parsed_dfs.push(df);

if let Some(n) = n_rows {
if num_rows >= n {
let len = n - parsed_dfs
.iter()
.map(|df: &DataFrame| df.height())
.sum::<usize>();
if std::env::var("POLARS_VERBOSE").is_ok() {
eprintln!("sliced off {} rows of the 'DataFrame'. These lines were read because they were in a single chunk.", df.height() - n)
}
parsed_dfs.push(df.slice(0, len));
break;
}
}
parsed_dfs.push(df);
}

let df = {
Expand Down

0 comments on commit 063b22d

Please sign in to comment.