-
Notifications
You must be signed in to change notification settings - Fork 915
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
Refactor CategoricalIndex.__init__, make .ordered and .categories properties from the CategoricalDtype #14979
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple comments. What is your merge plan for this? Should we test with other RAPIDS libraries, or slow down on merging breaking changes for a bit?
if out_col.ordered: | ||
out_col = column.build_categorical_column( | ||
def as_ordered(self, ordered: bool): | ||
if self.dtype.ordered != ordered: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather flip the if/else and structure this as an early exit.
If no work is needed (self.dtype.ordered == ordered
), return self
immediately.
Otherwise return the longer result of build_categorical_column
.
@@ -846,3 +846,8 @@ def test_empty_series_category_cast(ordered): | |||
|
|||
assert_eq(expected, actual) | |||
assert_eq(expected.dtype.ordered, actual.dtype.ordered) | |||
|
|||
|
|||
def test_categoricaldtype_ordered_not_settable(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_categoricaldtype_ordered_not_settable(): | |
def test_categorical_dtype_ordered_not_settable(): |
I think this change can wait until after GTC. Once |
Closing in favor of #15475 |
…mn and CategoricalDtype (#15475) A rehash of #14979 The `CategoricalDtype.ordered` behavior matches `pandas.CategoricalDtype.ordered` behavior. Also combines `as_ordered` and `as_unordred` into 1 method, and avoids to `as_index` casts that are already performed elsewhere Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: #15475
Description
In pandas,
.ordered
and.categories
are defined on theCategoricalDtype
and are not settable. Additionally, ensuring that they are only defined on the dtype and not also on the column so they don't go out-of-syncChecklist