Is there any way to check a Dataframe to see why this error would be returned when running a function on a DF? The error message is too vague. I got this error when running:
unique!(df,[col1,col2,col3])
I’ve only have only received this error on 1 dataset and I clean out missing values beforehand and don’t use undef.
StackTrace
ERROR: UndefRefError: access to undefined reference
Stacktrace:
[1] getindex
@ .\essentials.jl:917 [inlined]
[2] _broadcast_getindex
@ .\broadcast.jl:644 [inlined]
[3] _getindex
@ .\broadcast.jl:674 [inlined]
[4] _broadcast_getindex
@ .\broadcast.jl:650 [inlined]
[5] getindex
@ .\broadcast.jl:610 [inlined]
[6] copyto_widen!(res::Vector{…}, bc::Base.Broadcast.Broadcasted{…}, pos::Int64, col::Int64)
@ DataFrames C:\Users\programmer8\.julia\packages\DataFrames\kcA9R\src\other\broadcasting.jl:27
[7] copy(bc::Base.Broadcast.Broadcasted{DataFrames.DataFrameStyle, Tuple{…}, typeof(coalesce), Tuple{…}})
@ DataFrames C:\Users\programmer8\.julia\packages\DataFrames\kcA9R\src\other\broadcasting.jl:77
[8] materialize(bc::Base.Broadcast.Broadcasted{DataFrames.DataFrameStyle, Nothing, typeof(coalesce), Tuple{…}})
@ Base.Broadcast .\broadcast.jl:872
[9] top-level scope
@ c:\data\process.jl:111
Some type information was truncated. Use `show(err)` to see complete types.
If I guessed right, it’ll show for each column whether its elements can have a reference and if so, whether they are all assigned. If you see 0, 0 then that’s a column that can throw the error. If that’s the case, you’ll have to reevaluate how you’re instantiating the DataFrame, and you’ll also have to consider the columns that can’t have references because those elements just silently hold garbage values if not assigned.
You’ll need to explain the context, paste exact code, and paste the full stack trace. I could imagine it happening with eachindex(::DataFrame) but that’s not happening. evidently happening but shouldn’t.
Yeah that could be a problem, hence the recommendations to paste the code and stacktrace. If you can’t reproduce the DataFrame object directly, could you at least show typeof(df), eltype.(eachcol(df)) as well?
this is not how you do it. You want to use isassigned(col, idx) to check if a given index in a column is assigned or not, before trying to access it (which is what ismissing.(col) would do)