-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,18 @@ def names(self): | |
def names(self, value): | ||
value = [None] * self.nlevels if value is None else value | ||
assert len(value) == self.nlevels | ||
|
||
if len(value) == len(set(value)): | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kkraus14
Collaborator
|
||
# IMPORTANT: if the provided names are unique, | ||
# we reconstruct self._data with the names as keys. | ||
# If they are not unique, the keys of self._data | ||
# and self._names will be different, which can lead | ||
# to unexpected behaviour in some cases. This is | ||
# definitely buggy, but we can't disallow non-unique | ||
# names either... | ||
self._data = self._data._create_unsafe( | ||
dict(zip(value, self._data.values())) | ||
) | ||
self._names = pd.core.indexes.frozen.FrozenList(value) | ||
|
||
def rename(self, names, inplace=False): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I wonder if we should track whether the names are unique / match the underlying keys instead of always calculating the
set(value)
here.