You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change up MultiIndex.rename to be an alias for MultiIndex.set_names.
Index.rename : takes single object
MultiIndex.set_names, Index.set_names - same type signature: take list of names [Index.set_names can only take iterable of length 1)
MultiIndex.rename - synonym for set_names
So if you want to do something generically, you should use set_names (just like you would with other attributes). If you expect a non-MI index, then you could use rename with a string, etc.
I personally think that this behavior is how it should work for Index. Everyone okay with this? I'd prefer not to do type sniffing if at all possible.
ind=Index(range(10))
ind.rename(["apple"], inplace=True)
print(ind.name) # ['apple']print(ind.names) # [['apple']]ind.set_names('apple') # Fails with error that it's too long
The text was updated successfully, but these errors were encountered:
@jreback there's no set_name defined, so that's okay. Have to leave in this behavior, because levels are converted to indices and are given tuples as names in some parts of the library/tests - so on rename, I don't think it's worth it to check (and it's not very important either)
Change up
MultiIndex.rename
to be an alias forMultiIndex.set_names
.Index.rename
: takes single objectMultiIndex.set_names
,Index.set_names
- same type signature: take list of names [Index.set_names can only take iterable of length 1)MultiIndex.rename
- synonym forset_names
So if you want to do something generically, you should use
set_names
(just like you would with other attributes). If you expect a non-MI index, then you could userename
with a string, etc.cc @jreback
I personally think that this behavior is how it should work for Index. Everyone okay with this? I'd prefer not to do type sniffing if at all possible.
The text was updated successfully, but these errors were encountered: