Skip to content

Commit

Permalink
Force single chunk in concat_rows (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-khong authored Jun 29, 2023
1 parent 78ceb27 commit ae52e87
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion native/explorer/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn df_concat_rows(
out_df.vstack_mut(&df)?;
}
// Follows recommendation from docs and rechunk after many vstacks.
out_df.rechunk();
out_df.as_single_chunk_par();
Ok(ExDataFrame::new(out_df))
}

Expand Down
10 changes: 10 additions & 0 deletions test/explorer/data_frame_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,16 @@ defmodule Explorer.DataFrameTest do
fn -> DF.concat_rows(df1, DF.new(x: [7, 8, 9], y: [10, 11, 12])) end
end

test "concat_rows/2 rechunking logic when nil is introduced in the new dataframe" do
# this may panic without forced rechunking
df =
DF.new(x: [1.0, 2.0], y: [2.0, 3.0])
|> DF.concat_rows(DF.new(x: [nil], y: [nil]))
|> DF.mutate(z: correlation(x, y))

assert abs(df[:z][0] - 1.0) < 1.0e-4
end

describe "distinct/2" do
test "with lists", %{df: df} do
df1 = DF.distinct(df, [:year, :country])
Expand Down

0 comments on commit ae52e87

Please sign in to comment.