Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between `CategoricalArray` constructor and `categorical` function

Tags:

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?

like image 648
Cameron Bieganek Avatar asked Aug 26 '21 16:08

Cameron Bieganek


1 Answers

categorical supports compress keyword argument as opposed to CategoricalArray.

like image 105
Bogumił Kamiński Avatar answered Sep 19 '22 19:09

Bogumił Kamiński