-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug or Feature: fit(Histogram,...)
and DataFrames
#266
Comments
This was an intentional change introduced in #248. After a bit of discussion we decided that it doesn't make sense to have a weight vector that Do you have anything to add here, @nalimilan? |
@ararslan Would it make sense to add automatic conversion for |
We don't want this package to depend on DataArrays or NullableArrays, so the best we could do would be to add a conversion to |
Oh, no, you're right. I'm actually not sure why this is happening. |
@0kto Are there missing values in julia> d = @data([1, 2, NA, 4])
4-element DataArrays.DataArray{Int64,1}:
1
2
NA
4
julia> weights(d)
ERROR: MethodError: no method matching StatsBase.Weights{#7#S<:Real,#8#T<:Real,#9#V<:AbstractArray{T<:Real,1}}(::DataArrays.DataArray{Int64,1}, ::DataArrays.NAtype)
Closest candidates are:
StatsBase.Weights{#7#S<:Real,#8#T<:Real,#9#V<:AbstractArray{T<:Real,1}}{V<:AbstractArray{T<:Real,1}}(::V<:AbstractArray{T<:Real,1}) at /Users/rory/.julia/v0.5/StatsBase/src/weights.jl:63
StatsBase.Weights{#7#S<:Real,#8#T<:Real,#9#V<:AbstractArray{T<:Real,1}}{S<:Real,V<:AbstractArray{T<:Real,1}}(::V<:AbstractArray{T<:Real,1}, ::S<:Real) at /Users/rory/.julia/v0.5/StatsBase/src/weights.jl:63
StatsBase.Weights{#7#S<:Real,#8#T<:Real,#9#V<:AbstractArray{T<:Real,1}}{T}(::Any) at sysimg.jl:53
in weights(::DataArrays.DataArray{Int64,1}) at /Users/rory/.julia/v0.5/StatsBase/src/weights.jl:71 vs julia> d = @data([1, 2, 4])
3-element DataArrays.DataArray{Int64,1}:
1
2
4
julia> weights(d)
3-element StatsBase.Weights{Int64,Int64,DataArrays.DataArray{Int64,1}}:
1
2
4 |
Yes, the not all coordinates carry a signal |
Ahh, okay. Yeah, that behaviour is intentional, but I could be convinced otherwise. |
I maintain that it doesn't really make sense to allow the case where the sum of the weights is missing. What behavior would you expect that to exhibit? Since DataArrays depends on StatsBase, perhaps we should add an explicit |
I am home, so I can write a bit more detailed. After reading your comments I identify two problems for my use case: The first is that even for dataTuple a DataFrame column is not allowed. That means that The second issue is the one with the nullable arrays as weights. |
Well, I guess that is a hack to get things to work :) not having to deal with NAs at that level makes things easier, but I guess I could convert everything from NA to 0, and apply a mask to the endresults. |
Seems like that should be a separate function though (e.g., |
Actually purging every row with NA signal before handing everything to Histogram is the best option for my aims. |
We can't really mention FWIW, Also see JuliaStats/DataArrays.jl#249. |
Hi all,
I am relying quite a bit on Histograms in my scripts for my PhD, and I often calculate intensities of 2D detectors by supplying coordinates
x
,y
and the signal intensityI
as weight to thefit(Histogram,(x,y),weights(I)
. This is immideatly plottable via PyPlotsplt.imshow()
, etcSince I get my data from DataFrames, a typical command looks like:
This stopped working, instead I have to convert my DataFrames:
was that intentional?
The text was updated successfully, but these errors were encountered: