-
Notifications
You must be signed in to change notification settings - Fork 195
Closed
Description
i can only compute a weighted mean from a dataframe object after converting the column x to a float array. I don't understand why, since DataArray <: AbstractArray is true?
julia> df = DataFrame(x = rand(3),w=rand(3))
3x2 DataFrame
| Row | x | w |
|-----|----------|-----------|
| 1 | 0.226874 | 0.266516 |
| 2 | 0.346735 | 0.57437 |
| 3 | 0.232796 | 0.0512731 |
julia> mean(df[:x],WeightVec(df[:w]))
ERROR: `start` has no method matching start(::WeightVec{Float64,DataArray{Float64,1}})
in reduced_dims at reducedim.jl:17
in mean at /Users/florianoswald/.julia/v0.3/DataArrays/src/reducedim.jl:335
julia> mean(array(df[:x]),WeightVec(df[:w]))
0.30438070685782537
julia> methods(mean)
...
mean(v::AbstractArray{T,N},w::WeightVec{W<:Real,Vec<:AbstractArray{T<:Real,1}}) at /Users/florianoswald/.julia/v0.3/StatsBase/src/weights.jl:234
...
julia> typeof(df[:x])
DataArray{Float64,1} (constructor with 1 method)
julia> DataArray <: AbstractArray
true
Metadata
Metadata
Assignees
Labels
No labels