Skip to content

Conversation

jbrockmendel
Copy link
Member

Comment on lines 545 to 550
warnings.filterwarnings(
"ignore",
"Constructing a Categorical with a dtype and values",
FutureWarning,
)
res = cls._from_sequence(scalars, dtype=dtype)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens here once the deprecation is enforced?

Comment on lines 1181 to +1182
codes = recode_for_categories(
cat.codes, cat.categories, new_dtype.categories, copy=False
cat.codes, cat.categories, new_dtype.categories, copy=False, warn=False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the deprecation is enforced, do we still need to pass the flag on whether to allow values outside the categories?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the flag will become a "should we raise" flag, and will still be needed bc the answer will be "no" for set_categories

@@ -258,6 +258,12 @@ def _is_dtype_compat(self, other: Index) -> Categorical:
else:
values = other

codes = self.categories.get_indexer(values)
if ((codes == -1) & ~values.isna()).any():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the check on L269 with this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think not, will check and update

Comment on lines 131 to 132
# [c, None, None, dtype2, dtype2],
# [c, ["x", "y"], False, None, dtype2],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or uncomment/update?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, will update

@mroeschke mroeschke requested a review from rhshadrach August 25, 2025 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: astype method fails to raise errors for category data type API: Categorical constructor with dtype raise instead of casting to NA
2 participants