Skip to content

Commit

Permalink
Add lazy data frame test case for relocate (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
thehabbos007 authored Jun 16, 2023
1 parent 89ffcfa commit 441d219
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions test/explorer/data_frame/lazy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,27 @@ defmodule Explorer.DataFrame.LazyTest do
end
end

describe "relocate/3" do
test "with multiple columns" do
ldf =
DF.new(
[
first: ["a", "b", "a"],
second: ["x", "y", "z"],
third: [2.2, 3.3, nil],
last: [1, 3, 1]
],
lazy: true
)

ldf1 = DF.relocate(ldf, ["third", "second"], before: "first")
assert ldf1.names == ["third", "second", "first", "last"]

df = DF.collect(ldf1)
assert DF.dump_csv(df) == {:ok, "third,second,first,last\n2.2,x,a,1\n3.3,y,b,3\n,z,a,1\n"}
end
end

describe "rename/2" do
test "renames a column" do
ldf = DF.new([a: [1, 2, 3], b: ["a", "b", "c"]], lazy: true)
Expand Down
6 changes: 3 additions & 3 deletions test/explorer/data_frame_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1951,8 +1951,8 @@ defmodule Explorer.DataFrameTest do
assert DF.to_columns(df4) == %{"a" => [1], "b" => [1]}
end

describe "relocate/2" do
test "with single column and relative" do
describe "relocate/3" do
test "with single column" do
df =
DF.new(
first: ["a", "b", "a"],
Expand All @@ -1976,7 +1976,7 @@ defmodule Explorer.DataFrameTest do
assert df3.names == ["second", "third", "last", "first"]
end

test "with multiple columns and relative" do
test "with multiple columns" do
df =
DF.new(
first: ["a", "b", "a"],
Expand Down

0 comments on commit 441d219

Please sign in to comment.