Skip to content

Commit

Permalink
add tests and news
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins committed Apr 9, 2024
1 parent 22c6a68 commit 8a1e018
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
* Ensure that `allunique(::AbstractDataFrame, ::Any)` always gets
interpreted as test for uniqueness of rows in the first positional argument
([#3434](https://github.com/JuliaData/DataFrames.jl/issues/3434))
* Make sure that an empty vector of `Any` or of `AbstractVector` is treated as having
no columns when a data frame is being processed with `combine`/`select`/`transform`.
([#3435](https://github.com/JuliaData/DataFrames.jl/issues/3435))

# DataFrames.jl v1.6.1 Release Notes

Expand Down
18 changes: 18 additions & 0 deletions test/select.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3024,4 +3024,22 @@ end
@test_throws ArgumentError combine(gdf, :x => (x -> x[1] == 2 ? "x" : cr) => AsTable)
end

@testset "empty vector" begin
df = DataFrame(a=1:3)

@test_throws ArgumentError select(df, :a => (x -> Vector{Any}[]))

for T in (Vector{Any}, Any, NamedTuple{(:x,),Tuple{Int64}})
v = combine(df, :a => (x -> T[])).a_function
@test isempty(v)
@test eltype(v) === T
end

@test size(combine(df, :a => (x -> Vector{Any}[]) => AsTable)) == (0, 0)
@test size(combine(df, :a => (x -> Any[]) => AsTable)) == (0, 0)
df2 = combine(df, :a => (x -> NamedTuple{(:x,),Tuple{Int64}}[]) => AsTable)
@test size(df2) == (0, 1)
@test eltype(df2.x) === Int
end

end # module

0 comments on commit 8a1e018

Please sign in to comment.