diff --git a/src/abstractdataframe/abstractdataframe.jl b/src/abstractdataframe/abstractdataframe.jl index cdf308f059..ac6ebe0503 100644 --- a/src/abstractdataframe/abstractdataframe.jl +++ b/src/abstractdataframe/abstractdataframe.jl @@ -722,6 +722,7 @@ function _colinfo{T<:AbstractDataFrame}(dfs::Vector{T}) coltyps[idx] = promote_type(oldtyp, ct) end nonnull_ct[idx] += !_isnullable(col) + similars[idx] = expandsimilarpool(similars[idx], df[idx]) else # new column push!(colindex, cn) push!(coltyps, ct) @@ -741,6 +742,20 @@ function _colinfo{T<:AbstractDataFrame}(dfs::Vector{T}) coltyps, colnams, similars end +function expandsimilarpool{T,R<:Integer,N}(c1::PooledDataArray{T,R,N}, c2) + # expand pool to make room for all levels + pool = levels([levels(c1); levels(c2)]) + # doesn't need any refs + norefs = DataArrays.RefArray(Array{DataArrays.DEFAULT_POOLED_REF_TYPE,N}()) + # keep it compact (update the type of norefs) + compact(PooledDataArray(norefs, pool)) +end + +function expandsimilarpool(c1, c2) + c1 +end + + ############################################################################## ## ## Hashing diff --git a/test/grouping.jl b/test/grouping.jl index c8fe50f9b3..18dbd0b1f3 100644 --- a/test/grouping.jl +++ b/test/grouping.jl @@ -36,4 +36,8 @@ module TestGrouping x = pool(collect(1:20)) df = DataFrame(v1=x, v2=x) groupby(df, [:v1, :v2]) + + a = DataFrame(x=pool(1:200)) + b = DataFrame(x=pool(100:300)) + vcat(a,b) end