-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: simplify MultiIndex._shallow_copy #32772
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -990,15 +990,11 @@ def _constructor(self): | |
def _shallow_copy(self, values=None, **kwargs): | ||
if values is not None: | ||
names = kwargs.pop("names", kwargs.pop("name", self.names)) | ||
# discards freq | ||
kwargs.pop("freq", None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dropping this silently makes no sense, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
return MultiIndex.from_tuples(values, names=names, **kwargs) | ||
|
||
result = self.copy(**kwargs) | ||
result._cache = self._cache.copy() | ||
# GH32669 | ||
if "levels" in result._cache: | ||
del result._cache["levels"] | ||
result._cache.pop("levels", None) # GH32669 | ||
return result | ||
|
||
def _shallow_copy_with_infer(self, values, **kwargs): | ||
|
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.
do we need to worry about both name and names being passed?
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.
MultiIndex.from_tuples
only acceptsnames
, and Mi usesname
in some locations, so yes (but it a part of the ickyness of MultiIndex, so should ideally be refactored away).