-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
CLN: remove CategoricalIndex._create_from_codes #36342
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
Conversation
@@ -211,29 +211,6 @@ def __new__( | |||
|
|||
return cls._simple_new(data, name=name) | |||
|
|||
def _create_from_codes(self, codes, dtype=None, name=None): |
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.
rather than delete this, could this be something like
def _create_from_codes(self, codes, name=None):
name = name if name else self.name
cat = self._data._from_backing_data(codes)
return type(self)._simple_new(cat, name=name)
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.
it only saves 1 line, and id rather have fewer constructor methods
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.
don't we have the same code duplicated 4 times. (except that name should be lib._no_default here)
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.
yes. the ongoing process is to share more of this with the other ndarray-backed-ea-indexes
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.
ahh. so instead of the parameter name being codes
it would be more generic? wouldn't this give more opportunities for de-duplication and all numpy backed indexes could have a _create_from_codes
called say ``_from_backing_data` to be consistent with the underlying array
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.
im hopeful but not there yet. theres a lot of special cases in the DTI/TDI code because of .freq
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.
yeah the purpose is to avoid special casing things as much as possible; here the constructor is special cases.
Update some constructor calls in Categorical