Skip to content

Recode does not maintain ordered type #421

@EssamWisam

Description

@EssamWisam

See

using ScientificTypes

julia> x = categorical([1, 2, 3, 4, 5], ordered = true)
5-element CategoricalArray{Int64,1,UInt32}:
 1
 2
 3
 4
 5

julia> scitype(x)
AbstractVector{OrderedFactor{5}} (alias for AbstractArray{OrderedFactor{5}, 1})

julia> y = recode(x, 5 => 9)
5-element CategoricalArray{Int64,1,UInt32}:
 1
 2
 3
 4
 9

julia> scitype(y)
AbstractVector{Multiclass{5}} (alias for AbstractArray{Multiclass{5}, 1})

It's as if ordered = true is no longer the case after recode. Why is that the case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions