I have this issue with DataFramesMeta
using DataFrames, DataFramesMeta, StatsBase
julia> d = DataFrame(a=1:10,b = 2.0 * (1:10),w=Weights([1,zeros(9)...]))
10×3 DataFrames.DataFrame
│ Row │ a │ b │ w │
├─────┼────┼──────┼─────┤
│ 1 │ 1 │ 2.0 │ 1.0 │
│ 2 │ 2 │ 4.0 │ 0.0 │
│ 3 │ 3 │ 6.0 │ 0.0 │
│ 4 │ 4 │ 8.0 │ 0.0 │
│ 5 │ 5 │ 10.0 │ 0.0 │
│ 6 │ 6 │ 12.0 │ 0.0 │
│ 7 │ 7 │ 14.0 │ 0.0 │
│ 8 │ 8 │ 16.0 │ 0.0 │
│ 9 │ 9 │ 18.0 │ 0.0 │
│ 10 │ 10 │ 20.0 │ 0.0 │
julia> @linq d |>
@where(:a .>3) |>
@select(b=mean(:b,:w))
ERROR: ArgumentError: reduced dimension(s) must be integers
Stacktrace:
[1] reduced_indices(::Tuple{Base.OneTo{Int64}}, ::Array{Float64,1}) at ./reducedim.jl:35
[2] reducedim_initarray at ./reducedim.jl:73 [inlined]
[3] mean(::Array{Float64,1}, ::Array{Float64,1}) at ./statistics.jl:57
[4] (::###700#27{DataFrames.DataFrame})(::Array{Float64,1}, ::Array{Float64,1}) at /Users/florian.oswald/.julia/v0.6/DataFramesMeta/src/DataFramesMeta.jl:70
julia> @linq d |>
@where(:a .>3) |>
@select(b=StatsBase.mean(:b,:w))
ERROR: MethodError: Cannot `convert` an object of type Expr to an object of type DataFramesMeta.SymbolParameter
This may have arisen from a call to the constructor DataFramesMeta.SymbolParameter(...),
since type constructors fall back to convert methods.
From the first error I infer that mean
is dispatching to Base.mean
because this is where this error comes from. How can I make it use the version that accepts a Weights
vector?