Skip to content

Commit

Permalink
fix: Copy height in .vstack() for empty dataframes (#19641) (#19642)
Browse files Browse the repository at this point in the history
  • Loading branch information
letkemann authored Nov 5, 2024
1 parent 37475f3 commit 0d7f462
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 0d7f462

Please sign in to comment.