Skip to content

subsetting a Weights vector does not return a weight vector #371

@floswald

Description

@floswald
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   │
├─────┼────┼──────┼─────┤
│ 112.01.0 │
│ 224.00.0 │
│ 336.00.0 │
│ 448.00.0 │
│ 5510.00.0 │
│ 6612.00.0 │
│ 7714.00.0 │
│ 8816.00.0 │
│ 9918.00.0 │
│ 101020.00.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions