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: Copy height in .vstack() for empty dataframes (#19641) #19642

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions crates/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ impl DataFrame {
self.width(), other.width(),
);
self.columns.clone_from(&other.columns);
self.height = other.height;
return Ok(self);
}

Expand Down Expand Up @@ -3567,6 +3568,21 @@ mod test {
assert_eq!(df.first_col_n_chunks(), 2)
}

#[test]
fn test_vstack_on_empty_dataframe() {
let mut df = DataFrame::empty();

let df_data = df! {
"flt" => [1., 1., 2., 2., 3., 3.],
"int" => [1, 1, 2, 2, 3, 3, ],
"str" => ["a", "a", "b", "b", "c", "c"]
}
.unwrap();

df.vstack_mut(&df_data).unwrap();
assert_eq!(df.height, 6)
}

#[test]
#[cfg(feature = "zip_with")]
#[cfg_attr(miri, ignore)]
Expand Down