Skip to content

Commit

Permalink
Fix combining DataFrames with a column of Missings (#1344)
Browse files Browse the repository at this point in the history
fixes #1280
  • Loading branch information
nicoleepp authored and alyst committed Jan 19, 2018
1 parent b19f5f2 commit 06c3523
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/abstractdataframe/abstractdataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,8 @@ Base.hcat(df1::AbstractDataFrame, df2::AbstractDataFrame, dfn::AbstractDataFrame

@generated function promote_col_type(cols::AbstractVector...)
T = mapreduce(x -> Missings.T(eltype(x)), promote_type, cols)
if T <: CategoricalValue
T = T.parameters[1]
if CategoricalArrays.iscatvalue(T)
T = CategoricalArrays.leveltype(T)
end
if any(col -> eltype(col) >: Missing, cols)
if any(col -> col <: AbstractCategoricalArray, cols)
Expand Down
4 changes: 4 additions & 0 deletions test/cat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ module TestCat
# vcat should be able to concatenate different implementations of AbstractDataFrame (PR #944)
@test vcat(view(DataFrame(A=1:3),2),DataFrame(A=4:5)) == DataFrame(A=[2,4,5])

# vcat should be able to combine a DataFrame with a column full of Missings
df = DataFrame(A=1:3, B=missing)
@test isequal(vcat(df, df), DataFrame(A=repeat(1:3, outer=2), B=missing))

@testset "vcat >2 args" begin
@test vcat(DataFrame(), DataFrame(), DataFrame()) == DataFrame()
df = DataFrame(x = trues(1), y = falses(1))
Expand Down

0 comments on commit 06c3523

Please sign in to comment.