Difference between `CategoricalArray` constructor and `categorical` function

Viewed 47

The CategoricalArray constructor and the categorical function from CategoricalArrays.jl seem to be nearly identical in behavior:

julia> using CategoricalArrays

julia> x = CategoricalArray(["a", "b", "c"]; ordered=true, levels=["c", "b", "a"])
3-element CategoricalArray{String,1,UInt32}:
 "a"
 "b"
 "c"

julia> y = categorical(["a", "b", "c"]; ordered=true, levels=["c", "b", "a"])
3-element CategoricalArray{String,1,UInt32}:
 "a"
 "b"
 "c"

julia> x == y
true

Is there any notable difference between CategoricalArray and categorical? If they're basically the same, then what's the reason for including the redundant categorical function?

1 Answers

categorical supports compress keyword argument as opposed to CategoricalArray.

Related