Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make levels return a CategoricalArray #390

Open
nalimilan opened this issue Apr 1, 2022 · 1 comment
Open

Make levels return a CategoricalArray #390

nalimilan opened this issue Apr 1, 2022 · 1 comment
Labels
Milestone

Comments

@nalimilan
Copy link
Member

Having levels automatically unwrap CategoricalValues is a bit inconsistent with the fallback defined in DataAPI, which is equivalent to sort!(unique(x)). This is mostly historical, as levels was defined in CategoricalArrays first. But it can make some implementations more complex when the goal is to return a CategoricalArray (JuliaData/DataFrames.jl#3031 (comment)).

So it could make sense to make levels return a CategoricalArray in the next breaking release. This should be mostly transparent for users as long as they don't apply functions like string operations to levels. This could end up being inconvenient in some cases though. It would also force allocating a new array each time levels is called (as we probably don't want to store a CategoricalArray inside the CategoricalPool for that).

Cc: @bkamins

@nalimilan nalimilan added this to the 0.11 milestone Apr 1, 2022
@bkamins
Copy link
Member

bkamins commented Apr 1, 2022

Let us start with listing cases when levels is intended to be used and then make a decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants