Hey there,
I noticed that it is not possible to @group
by an abstract typed column
and I’m wondering if this is deliberately so or just a bug.
julia> df = DataFrame(foo=Real[])
0×1 DataFrame
julia> push!(df, Dict(:foo => 1)); push!(df, Dict(:foo => 1.))
2×1 DataFrame
│ Row │ foo │
├─────┼─────┤
│ 1 │ 1 │
│ 2 │ 1.0 │
julia> grouped_df = @from i in df begin
@group i by i.foo into g
@select {foo=key(g)}
@collect DataFrame
end
ERROR: MethodError: Cannot `convert` an object of type QueryOperators.EnumerableMap{Any,QueryOperators.EnumerableGroupBySimple{Grouping{Real,NamedTuple{(:foo,),Tuple{Real}}},Real,NamedTuple{(:foo,),Tuple{Real}},QueryOperators.EnumerableIterable{NamedTuple{(:foo,),Tuple{Real}},TableTraitsUtils.TableIterator{NamedTuple{(:foo,),Tuple{Real}},Tuple{Array{Real,1}}}},getfield(Main, Symbol("##37#39"))},getfield(Main, Symbol("##38#40"))} to an object of type DataFrame
Closest candidates are:
convert(::Type{DataFrame}, ::AbstractArray{T,2} where T) at /home/jonas/.julia/packages/DataFrames/utxEh/src/dataframe/dataframe.jl:986
convert(::Type{DataFrame}, ::AbstractDict) at /home/jonas/.julia/packages/DataFrames/utxEh/src/dataframe/dataframe.jl:988
convert(::Type{S}, ::T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)) where {S, T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)} at /home/jonas/.julia/packages/CategoricalArrays/04bks/src/value.jl:66
...
Stacktrace:
[1] DataFrame(::QueryOperators.EnumerableMap{Any,QueryOperators.EnumerableGroupBySimple{Grouping{Real,NamedTuple{(:foo,),Tuple{Real}}},Real,NamedTuple{(:foo,),Tuple{Real}},QueryOperators.EnumerableIterable{NamedTuple{(:foo,),Tuple{Real}},TableTraitsUtils.TableIterator{NamedTuple{(:foo,),Tuple{Real}},Tuple{Array{Real,1}}}},getfield(Main, Symbol("##37#39"))},getfield(Main, Symbol("##38#40"))}) at /home/jonas/.julia/packages/IterableTables/Jkq8l/src/integrations/dataframes.jl:24
[2] collect(::QueryOperators.EnumerableMap{Any,QueryOperators.EnumerableGroupBySimple{Grouping{Real,NamedTuple{(:foo,),Tuple{Real}}},Real,NamedTuple{(:foo,),Tuple{Real}},QueryOperators.EnumerableIterable{NamedTuple{(:foo,),Tuple{Real}},TableTraitsUtils.TableIterator{NamedTuple{(:foo,),Tuple{Real}},Tuple{Array{Real,1}}}},getfield(Main, Symbol("##37#39"))},getfield(Main, Symbol("##38#40"))}, ::Type{DataFrame}) at /home/jonas/.julia/packages/Query/fzgEu/src/sinks/sink_type.jl:2
[3] top-level scope at none:0
The same thing works if I remove the type and do df = DataFrame(foo=[])
.