Home > front end >  Julia recode not defined
Julia recode not defined

Time:01-04

So I am learning Julia and I am trying to replace missing values with NaN values in my array with the help of recode function, like this : recode([1.0, missing, 2.0, missing], missing=>NaN)
But I get an error stating this :

UndefVarError: recode not defined

Stacktrace:
 [1] top-level scope
   @ In[18]:1
 [2] eval
   @ ./boot.jl:373 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1196

I can only find helping answers for older versions of Julia where the recode works perfectly but not for Julia 1.7.0
Does anyone know if it is deprecated or I am doing something wrong?

CodePudding user response:

You are most likely referring to the recode function that is defined in CategoricalArrays.jl package. Please load this package first:

using CategoricalArrays

CodePudding user response:

While the other answer tells you were is recode, note that you can also just use coalesce:

julia> coalesce.([1.0, missing, 2.0, missing], NaN)
4-element Vector{Float64}:
   1.0
 NaN
   2.0
 NaN
  • Related